var vendor = {
	pos_form_load : function(merchant_id, case_id) {		
		$(document.form.request_type).on('change', function(event){
			var control_group = $(document.form.bank).closest('.control-group');
			
			if($(this).val() == 'Tag-on'){
				control_group.css('visibility', 'visible');
			} else {
				control_group.css('visibility', 'hidden');
			}
		});
		
		$(document.form.outlet_id).change(function() {
			var outlet_id = $(this).val();
			var app_no = $(document.form.app_no).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_pos&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id" 
				+ "&a_no=" + encodeURIComponent(app_no) + "#app_no";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_pos&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id);
			}
		});
		
		
		$('table.pos_ezypay').children('tbody').children('tr').each(function(index, elmt){
			var first_tid_td = $(this).children('td.first_tid');
			
			first_tid_td.children('input:not([readonly="readonly"])').on('blur', function(event){
				var tr = $(this).closest('tr');
				var tid_no = tr.attr('data-tid');
				
				var first_tid = $(this).val();
				console.log(tr.siblings('tr[data-tid="' + tid_no + '"]'));
				tr.siblings('tr[data-tid="' + tid_no + '"]').each(function(index, elmt){
					$(this).children('td.first_tid').children('input').val(+first_tid + (index + 1));
				});
			});
		});
		
		$('table.amex_ezypay').children('tbody').children('tr').each(function(index, elmt){
			var first_tid_td = $(this).children('td.first_tid');
			
			first_tid_td.children('input:not([readonly="readonly"])').on('blur', function(event){
				var tr = $(this).closest('tr');
				var tid_no = tr.attr('data-tid');
				
				var first_tid = $(this).val();
				console.log(tr.siblings('tr[data-tid="' + tid_no + '"]'));
				tr.siblings('tr[data-tid="' + tid_no + '"]').each(function(index, elmt){
					$(this).children('td.first_tid').children('input').val(+first_tid + (index + 1));
				});
			});
		});

		
		$('body').on('click', vendor.close_appendix);
		
		$('table.appendix').children('tbody').children('tr').each(function(index, elmt){
			var btn = $(this).children('td:last').children('button.btn');
			
			if(btn.hasClass('dcc')){
				btn.on('click', function(event){
					event.stopPropagation();
					vendor.open_appendix_dcc(merchant_id, case_id);
				})
			}
			else if(btn.hasClass('unionpay')){
				btn.on('click', function(event){
					event.stopPropagation();
					vendor.open_appendix_unionpay(merchant_id, case_id, $(this).attr('data-vendor'));
				})
			}
			else if(btn.hasClass('partner')){
				btn.on('click', function(event){
					event.stopPropagation();
					vendor.open_appendix_partner(merchant_id, case_id, $(this).attr('data-partner'));
				})
			}
		});
	},
	
	esapl_form_load : function(merchant_id, case_id) {		
		$(document.form.outlet_id).on('change', function() {
			var outlet_id = $(this).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=esa_pl&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=esa_pl&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id);
			}
		});
		
		
		//Bind this keypress function to all of the input tags
		$("input").keypress(function (evt) {
			var charCode = evt.charCode || evt.keyCode;
			if (charCode  == 13) { //Enter key's keycode
				return false;
			}
		});
		
				
	},
	
	nonesapl_form_load : function(merchant_id, case_id) {		
		$(document.form.outlet_id).on('change', function() {
			var outlet_id = $(this).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=non_esa_pl&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=non_esa_pl&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id);
			}
		});
		
		
		//Bind this keypress function to all of the input tags
		$("input").keypress(function (evt) {
			var charCode = evt.charCode || evt.keyCode;
			if (charCode  == 13) { //Enter key's keycode
				return false;
			}
		});
		
				
	},
	
	esaezypay_form_load : function(merchant_id, case_id) {		
		$(document.form.outlet_id).on('change', function() {
			var outlet_id = $(this).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=esa_ezypay&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=esa_ezypay&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id);
			}
		});
		
		
		//Bind this keypress function to all of the input tags
		$("input").keypress(function (evt) {
			var charCode = evt.charCode || evt.keyCode;
			if (charCode  == 13) { //Enter key's keycode
				return false;
			}
		});
		
				
	},
	
	nonesaezypay_form_load : function(merchant_id, case_id) {		
		$(document.form.outlet_id).on('change', function() {
			var outlet_id = $(this).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=non_esa_ezypay&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=non_esa_ezypay&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id);
			}
		});
		
		
		//Bind this keypress function to all of the input tags
		$("input").keypress(function (evt) {
			var charCode = evt.charCode || evt.keyCode;
			if (charCode  == 13) { //Enter key's keycode
				return false;
			}
		});
		
				
	},
	isNumberKey : function(evt){
		var charCode = (evt.which) ? evt.which : event.keyCode;
		if (charCode != 8 && charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 37 || charCode > 40))
			return false;

		vendor.calculate();
		
		return true;
		//return vendor.formatnumber(evt);
        //formatnumber(r); // 10,000.00
    },    
    
    isNumberKeyOnly : function(evt){
		var charCode = (evt.which) ? evt.which : event.keyCode;
		if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 37 || charCode > 40))
			return false;

		vendor.calculate();
		
		return true;
		//return vendor.formatnumber(evt);
        //formatnumber(r); // 10,000.00
    }, 
    
    isNumberKey2 : function(evt){
		var charCode = (evt.which) ? evt.which : event.keyCode;
		if (charCode != 8 && charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 37 || charCode > 40))
			return false;

		vendor.calculate2();
		
		return true;
		
    },    
    
      
    toFixed: function( number, precision ) {
        var multiplier = Math.pow( 10, precision );
        return Math.round( number * multiplier ) / multiplier;
    },
    
    roundNumber: function(number) {//function roundNumber(rnum, rlength) {
    	var decimals=2;
    	return Number(Math.round(number+'e'+decimals)+'e-'+decimals);//+(Math.round(number + "e+2")  + "e-2");
    },
    
    calculate : function(){
    	/*$('#txt_visa_percent').val()==""? $('#txt_visa_percent').val('0'): $('#txt_visa_percent').val($('#txt_visa_percent').val());
    	$('#txt_master_percent').val()==""? $('#txt_master_percent').val('0'): $('#txt_master_percent').val($('#txt_master_percent').val());
    	$('#txt_vmc_on_us').val()==""? $('#txt_vmc_on_us').val('0'): $('#txt_vmc_on_us').val($('#txt_vmc_on_us').val());
    	$('#txt_foreign_percent').val()==""? $('#txt_foreign_percent').val('0'): $('#txt_foreign_percent').val($('#txt_foreign_percent').val());
    	$('#txt_amex_on_us').val()==""? $('#txt_amex_on_us').val('0'): $('#txt_amex_on_us').val($('#txt_amex_on_us').val());*/
    	
    	//Calculate master %
    	if($('#txt_visa_percent').val().length>0  && parseFloat($('#txt_visa_percent').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_visa_percent').val()));
	    	$('#txt_master_percent').val(result.toFixed(2));//.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_visa_percent').val())>100){
    			mapUI.jq_message("Visa percentage cannot be more than 100%", 3);
    			$('#txt_visa_percent').val('0');
    		}
    		if($('#txt_visa_percent').val()==''){
    			$('#txt_visa_percent').val('0');
    		}
    			
    		$('#txt_master_percent').val('');
    		vendor.calculate();
    	}
    	
    	//Calculate not on us %
    	if($('#txt_vmc_on_us').val().length>0  && parseFloat($('#txt_vmc_on_us').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_vmc_on_us').val()));
	    	$('#txt_vmc_not_on_us').val(result.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_vmc_on_us').val())>100){
    			mapUI.jq_message("Visa/Master on us percentage cannot be more than 100%", 3);
    			$('#txt_vmc_on_us').val('0');
    		}
    		if($('#txt_vmc_on_us').val()==''){
    			$('#txt_vmc_on_us').val('0');
    		}
    			
    		$('#txt_vmc_not_on_us').val('');
    		vendor.calculate();
        }
    	
    	//Calculate local %
    	if($('#txt_foreign_percent').val().length>0  && parseFloat($('#txt_foreign_percent').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_foreign_percent').val()));
	    	$('#txt_local_percent').val(result.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_foreign_percent').val())>100){
    			mapUI.jq_message("Visa/Master foreign percentage cannot be more than 100%", 3);
    			$('#txt_foreign_percent').val('0');
    		}
    		if($('#txt_foreign_percent').val()==''){
    			$('#txt_foreign_percent').val('0');
    		}
    			
    		$('#txt_local_percent').val('');
    		vendor.calculate();
    	} 
    	
    	//Calculate amex not on us %
    	if($('#txt_amex_on_us').val().length>0  && parseFloat($('#txt_amex_on_us').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_amex_on_us').val()));
	    	$('#txt_amex_not_on_us').val(result.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_amex_on_us').val())>100){
    			mapUI.jq_message("Amex on us percentage cannot be more than 100%", 3);
    			$('#txt_amex_on_us').val('0');
    		}
    		if($('#txt_amex_on_us').val()==''){
    			$('#txt_amex_on_us').val('0');
    		}
    			
    		$('#txt_amex_not_on_us').val('');
    		vendor.calculate();
    	} 
    	
    	
    	//Calculate debit not on us %
    	if($('#txt_debit_on_us_percent').val().length>0  && parseFloat($('#txt_debit_on_us_percent').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_debit_on_us_percent').val()));
	    	$('#txt_debit_not_on_us_percent').val(result.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_debit_on_us_percent').val())>100){
    			mapUI.jq_message("Debit on us percentage cannot be more than 100%", 3);
    			$('#txt_debit_on_us_percent').val('0');
    		}
    		if($('#txt_debit_on_us_percent').val()==''){
    			$('#txt_debit_on_us_percent').val('0');
    		}
    			
    		$('#txt_debit_not_on_us_percent').val('');
    		vendor.calculate();
    	} 
    	
    	//Calculate total cost
    	if($('#txt_overhead_maintenance_cost').val()=="") $('#txt_overhead_maintenance_cost').val('0');
    	if($('#txt_edc_terminal_cost').val()=="") $('#txt_edc_terminal_cost').val('0');
    	if($('#txt_annual_leaseline_cost').val()=="") $('#txt_annual_leaseline_cost').val('0');
    	if($('#txt_onetimesetup_cost').val()=="") $('#txt_onetimesetup_cost').val('0');
    	if($('#txt_sim_cost1').val()=="") $('#txt_sim_cost1').val('0');
    	if($('#txt_tel_charges').val()=="") $('#txt_tel_charges').val('0');
    	if($('#txt_sponsorship_fee').val()=="") $('#txt_sponsorship_fee').val('0');
    	if($('#txt_amex_tag_on').val()=="") $('#txt_amex_tag_on').val('0');
    	if($('#txt_amex_signing_fee').val()=="") $('#txt_amex_signing_fee').val('0');
    	if($('#txt_setup_fee').val()=="") $('#txt_setup_fee').val('0');
    	if($('#txt_sim_cost2').val()=="") $('#txt_sim_cost2').val('0');

    	var totalcost = vendor.roundNumber(parseFloat($('#txt_overhead_maintenance_cost').val())+parseFloat($('#txt_edc_terminal_cost').val())+parseFloat($('#txt_annual_leaseline_cost').val())
    	+parseFloat($('#txt_onetimesetup_cost').val())+parseFloat($('#txt_sim_cost1').val())+parseFloat($('#txt_tel_charges').val())
    	+parseFloat($('#txt_sponsorship_fee').val())+parseFloat($('#txt_amex_tag_on').val())+parseFloat($('#txt_amex_signing_fee').val())
    	+parseFloat($('#txt_setup_fee').val()));
    	
    	$('#txt_total_less_cost').val(totalcost.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	
    	//Calculate EDCs
    	if($('#txt_wired_num').val()=="") $('#txt_wired_num').val('0');
    	if($('#txt_wired_cost').val()=="") $('#txt_wired_cost').val('0');
    	if($('#txt_wireless_num').val()=="") $('#txt_wireless_num').val('0');
    	if($('#txt_wireless_cost').val()=="") $('#txt_wireless_cost').val('0');
    	
    	var wtcost = vendor.roundNumber((parseFloat($('#txt_wired_num').val())*parseFloat($('#txt_wired_cost').val())));
    	var wltcost = vendor.roundNumber((parseFloat($('#txt_wireless_num').val())*parseFloat($('#txt_wireless_cost').val())));
    	var tnum= vendor.roundNumber(parseFloat($('#txt_wired_num').val())+parseFloat($('#txt_wireless_num').val()));
    	var ttcost= vendor.roundNumber(parseFloat(wtcost)+parseFloat(wltcost));
    	$('#txt_wired_tcost').val(wtcost.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_wireless_tcost').val(wltcost.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_total_num').val(tnum.toFixed(0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_total_tcost').val(ttcost.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	
    	//debit mdr input //other input
    	if($('#txt_debit_mdr').val()=="") $('#txt_debit_mdr').val('0');
    	
    	if($('#txt_terminal_rental_earning').val()=="") $('#txt_debit_mdr').val('0');
    	if($('#txt_no_mbbedc_terminal').val()=="") $('#txt_no_mbbedc_terminal').val('0');
    	if($('#txt_terminal_cost_edc_permonth').val()=="") $('#txt_terminal_cost_edc_permonth').val('0');
    	if($('#txt_intfee_petrol').val()=="") $('#txt_intfee_petrol').val('0');
    	if($('#txt_intfee_ffood').val()=="") $('#txt_intfee_ffood').val('0');
    	if($('#txt_intfee_insurance').val()=="") $('#txt_intfee_insurance').val('0');
    	if($('#txt_intfee_education').val()=="") $('#txt_intfee_education').val('0');
    	if($('#txt_intfee_government').val()=="") $('#txt_intfee_government').val('0');
    	if($('#txt_intfee_hypermarket').val()=="") $('#txt_intfee_hypermarket').val('0');
    	if($('#txt_visa_petrol').val()=="") $('#txt_visa_petrol').val('0');
    	if($('#txt_visa_gov').val()=="") $('#txt_visa_gov').val('0');
    	if($('#txt_visa_charities').val()=="") $('#txt_visa_charities').val('0');
    	if($('#txt_visa_emarket').val()=="") $('#txt_visa_emarket').val('0');
    	if($('#txt_visa_insurance').val()=="") $('#txt_visa_insurance').val('0');
    	if($('#txt_visa_supermarket').val()=="") $('#txt_visa_supermarket').val('0');
    	if($('#txt_visa_utilities').val()=="") $('#txt_visa_utilities').val('0');
    	if($('#txt_mc_petrol').val()=="") $('#txt_mc_petrol').val('0');
    	if($('#txt_mc_gov').val()=="") $('#txt_mc_gov').val('0');
    	if($('#txt_mc_charities').val()=="") $('#txt_mc_charities').val('0');
    	if($('#txt_mc_emarket').val()=="") $('#txt_mc_emarket').val('0');
    	if($('#txt_mc_insurance').val()=="") $('#txt_mc_insurance').val('0');
    	if($('#txt_mc_supermarket').val()=="") $('#txt_mc_supermarket').val('0');
    	if($('#txt_mc_utilities').val()=="") $('#txt_mc_utilities').val('0');
    	
    	if($('#txt_amex_playment_plan').val()=="") $('#txt_amex_playment_plan').val('0');
    	if($('#txt_amex_interchange').val()=="") $('#txt_amex_interchange').val('0');
    	if($('#txt_terminal_rental_earning').val()=="") $('#txt_terminal_rental_earnings').val('0');
    	
    	
    	//CALCULATION START HERE
    	var f5,f6,f8,f10,f12,c9,c10; //visa/master
    	var c12,c14,c15; //visa
    	var f22,f23,f24,f25,f26,f27,f28,g22,g23,g24,g25,g26,g27,g28 ;
    	var c128;//all calculation
    	
    	var f68,f70,f71,f76,f77,f78,f79f,f80,f81,f88,f89;
    	var c103,c106,c107,c108,c109,c110,c111,c112,c113,c114,c115,c116;
    	var f107,g107,f108,g108,c133,c134;
    	
    	//enter those auto calculation
    	var f69,f90,f109,h107,h108,h109;
    	var f11,c21;
    	var c17,c18,c19,c21,c22,c23,c24,c26,c27,c28,c29,c30,c31,c32,c33,c34,c35,c37,c39,c40,c41,c42,c44,c45,c46,c48,c49,c50,c51,c53,c54,c55,c56,c57,c58,c59;
    	var c60,c61,c62,c63,c64,c68,c69,c71,c72,c73,c75,c76,c79,c80,c81,c82,c84,c87,c90,c91,c92,c93,c94,c95,c96,c97,c98,c99,c101;
    	var c117,c119,c120,c121,c122,c123,c124,c126,c127,c129,c130,c131,c132,c136,c137,c138,c139,c140,c141,c143,c144,c145,c146;
    	var f9;
    	var f16,g16,h16,i16;
    	var f17,g17,h17,i17;
    	var f18,g18,h18,i18;
    	var f19,g19,h19,i19;
    	var f67;
    	var c89,c90,c91,c92,c93,c94,c95,c96,c97,c98,c99,c101;
    	
    	
    	$('#txt_mdr_on_us').val().length>0 ? f5= parseFloat($('#txt_mdr_on_us').val()) : f5="0";
    	$('#txt_mdr_off_us').val().length>0 ? f6= parseFloat($('#txt_mdr_off_us').val()) : f6="0";
    	
    	$('#txt_visa_percent').val().length>0 ? f8=parseFloat($('#txt_visa_percent').val()) : f8="0";
    	$('#txt_vmc_on_us').val().length>0 ? f10=parseFloat($('#txt_vmc_on_us').val()) : f10="0";
    	$('#txt_foreign_percent').val().length>0 ? f12=parseFloat($('#txt_foreign_percent').val()) : f12="0";
    	
    	$('#txt_master_percent').val().length>0 ? f9= parseFloat($('#txt_master_percent').val()) : f9="0";
    	$('#txt_vmc_not_on_us').val().length>0 ? f11= parseFloat($('#txt_vmc_not_on_us').val()) : f11="0";
    	$('#txt_local_percent').val().length>0 ? f13=parseFloat($('#txt_local_percent').val()) : f13="0";
    	$('#txt_amex_not_on_us').val().length>0 ? f69=parseFloat($('#txt_amex_not_on_us').val()) : f69="0";
    	$('#txt_amex_mdr').val().length>0 ? f67=parseFloat($('#txt_amex_mdr').val()) : f67="0";
    	
    	$('#txt_visa_petrol').val().length>0 ? f22=parseFloat($('#txt_visa_petrol').val()) : f22="0";
    	$('#txt_visa_gov').val().length>0 ? f23=parseFloat($('#txt_visa_gov').val()) : f23="0";
    	$('#txt_visa_charities').val().length>0 ? f24=parseFloat($('#txt_visa_charities').val()) : f24="0";
    	$('#txt_visa_emarket').val().length>0 ? f25=parseFloat($('#txt_visa_emarket').val()) : f25="0";
    	$('#txt_visa_insurance').val().length>0 ? f26=parseFloat($('#txt_visa_insurance').val()) : f26="0";
    	$('#txt_visa_supermarket').val().length>0 ? f27=parseFloat($('#txt_visa_supermarket').val()) : f27="0";
    	$('#txt_visa_utilities').val().length>0 ? f28=parseFloat($('#txt_visa_utilities').val()) : f28="0";
    	
    	
    	$('#txt_mc_petrol').val().length>0 ? g22=parseFloat($('#txt_mc_petrol').val()) : g22="0";
    	$('#txt_mc_gov').val().length>0 ? g23=parseFloat($('#txt_mc_gov').val()) : g23="0";
    	$('#txt_mc_charities').val().length>0 ? g24=parseFloat($('#txt_mc_charities').val()) : g24="0";
    	$('#txt_mc_emarket').val().length>0 ? g25=parseFloat($('#txt_mc_emarket').val()) : g25="0";
    	$('#txt_mc_insurance').val().length>0 ? g26=parseFloat($('#txt_mc_insurance').val()) : g26="0";
    	$('#txt_mc_supermarket').val().length>0 ? g27=parseFloat($('#txt_mc_supermarket').val()) : g27="0";
    	$('#txt_mc_utilities').val().length>0 ? g28=parseFloat($('#txt_mc_utilities').val()) : g28="0";
    	
    	
    	$('#txt_amex_on_us').val().length>0 ? f68=parseFloat($('#txt_amex_on_us').val()) : f68="0";
    	$('#txt_amex_playment_plan').val().length>0 ? f70=parseFloat($('#txt_amex_playment_plan').val()) : f70="0";
    	$('#txt_amex_interchange').val().length>0 ? f71=parseFloat($('#txt_amex_interchange').val()) : f71="0";
    	$('#txt_intfee_petrol').val().length>0 ? f76=parseFloat($('#txt_intfee_petrol').val()) : f76="0";
    	$('#txt_intfee_ffood').val().length>0 ? f77=parseFloat($('#txt_intfee_ffood').val()) : f77="0";
    	$('#txt_intfee_insurance').val().length>0 ? f78=parseFloat($('#txt_intfee_insurance').val()) : f78="0";
    	$('#txt_intfee_education').val().length>0 ? f79=parseFloat($('#txt_intfee_education').val()) : f79="0";
    	$('#txt_intfee_government').val().length>0 ? f80=parseFloat($('#txt_intfee_government').val()) : f80="0";
    	$('#txt_intfee_hypermarket').val().length>0 ? f81=parseFloat($('#txt_intfee_hypermarket').val()) : f81="0";
    	$('#txt_debit_mdr').val().length>0 ? f88=parseFloat($('#txt_debit_mdr').val()) : f88="0";
    	$('#txt_debit_on_us_percent').val().length>0 ? f89=parseFloat($('#txt_debit_on_us_percent').val()) : f89="0";
    	
    	
    	$('#txt_terminal_rental_earning').val().length>0 ? c103=parseFloat($('#txt_terminal_rental_earning').val()) : c103="0";
    	$('#txt_overhead_maintenance_cost').val().length>0 ? c106=parseFloat($('#txt_overhead_maintenance_cost').val()) : c106="0";
    	$('#txt_edc_terminal_cost').val().length>0 ? c107=parseFloat($('#txt_edc_terminal_cost').val()) : c107="0";
    	$('#txt_annual_leaseline_cost').val().length>0 ? c108=parseFloat($('#txt_annual_leaseline_cost').val()) : c108="0";
    	$('#txt_onetimesetup_cost').val().length>0 ? c109=parseFloat($('#txt_onetimesetup_cost').val()) : c109="0";
    	$('#txt_sim_cost1').val().length>0 ? c110=parseFloat($('#txt_sim_cost1').val()) : c110="0";
    	$('#txt_tel_charges').val().length>0 ? c111=parseFloat($('#txt_tel_charges').val()) : c111="0";
    	$('#txt_sponsorship_fee').val().length>0 ? c112=parseFloat($('#txt_sponsorship_fee').val()) : c112="0";
    	$('#txt_amex_tag_on').val().length>0 ? c113=parseFloat($('#txt_amex_tag_on').val()) : c113="0";
    	$('#txt_amex_signing_fee').val().length>0 ? c114=parseFloat($('#txt_amex_signing_fee').val()) : c114="0";
    	$('#txt_setup_fee').val().length>0 ? c115=parseFloat($('#txt_sim_cost2').val()) : c115="0";
    	$('#txt_sim_cost2').val().length>0 ? c116=parseFloat($('#txt_sim_cost2').val()) : c116="0";
    	
    	
    	$('#txt_wired_num').val().length>0 ? f107=parseFloat($('#txt_wired_num').val()) : f107="0";
    	$('#txt_wired_cost').val().length>0 ? f108=parseFloat($('#txt_wired_cost').val()) : f108="0";
    	$('#txt_wireless_num').val().length>0 ? g107=parseFloat($('#txt_wireless_num').val()) : g107="0";
    	$('#txt_wireless_cost').val().length>0 ? g108=parseFloat($('#txt_wireless_cost').val()) : g108="0";
    	$('#txt_no_mbbedc_terminal').val().length>0 ? c133=parseFloat($('#txt_no_mbbedc_terminal').val()) : c133="0";
    	$('#txt_terminal_cost_edc_permonth').val().length>0 ? c134=$('#txt_terminal_cost_edc_permonth').val() : c134="0";
    	
    	$('#txt_vl_normal').val().length>0 ? f16=parseFloat($('#txt_vl_normal').val()) : f16="0";
    	$('#txt_vf_normal').val().length>0 ? f17=parseFloat($('#txt_vf_normal').val()) : f17="0";
    	$('#txt_ml_normal').val().length>0 ? f18=parseFloat($('#txt_ml_normal').val()) : f18="0";
    	$('#txt_mf_normal').val().length>0 ? f19=parseFloat($('#txt_mf_normal').val()) : f19="0";
    	
    	
    	$('#txt_debit_not_on_us_percent').val().length>0 ? f90=parseFloat($('#txt_debit_not_on_us_percent').val()) : f90="0";
    	$('#txt_total_less_cost').val().length>0 ? c117=parseFloat($('#txt_total_less_cost').val()) : c117="0";
    	
    	/*$('#txt_vl_high').val().length>0 ? g16=parseFloat($('#txt_vl_high').val()) : g16="0";
    	$('#txt_vl_moto').val().length>0 ? h16=parseFloat($('#txt_vl_moto').val()) : h16="0";
    	$('#txt_vl_ecomm').val().length>0 ? i16=parseFloat($('#txt_vl_ecomm').val()) : i16="0";
    	
    	*/
    	/*$('#txt_vf_high').val().length>0 ? g17=parseFloat($('#txt_vf_high').val()) : g17="0";
    	$('#txt_vf_moto').val().length>0 ? h17=parseFloat($('#txt_vf_moto').val()) : h17="0";
    	$('#txt_vf_ecomm').val().length>0 ? i17=parseFloat($('#txt_vf_ecomm').val()) : i17="0";
    	
    	$('#txt_ml_high').val().length>0 ? g18=parseFloat($('#txt_ml_high').val()) : g18="0";
    	$('#txt_ml_moto').val().length>0 ? h18=parseFloat($('#txt_ml_moto').val()) : h18="0";
    	$('#txt_ml_ecomm').val().length>0 ? i18=parseFloat($('#txt_ml_ecomm').val()) : i18="0";
    	
    	$('#txt_mf_high').val().length>0 ? g19=parseFloat($('#txt_mf_high').val()) : g19="0";
    	$('#txt_mf_moto').val().length>0 ? h19=parseFloat($('#txt_mf_moto').val()) : h19="0";
    	$('#txt_mf_ecomm').val().length>0 ? i19=parseFloat($('#txt_mf_ecomm').val()) : i19="0"; */	    	
   	    	
    	c9= $('#txt_total_sales').val();
    	var splitc9= c9.split(',');
    	c9 = splitc9.join("");
    	
    	c10= $('#txt_annual_visa_master_sales').val();
    	var splitc10= c10.split(',');
    	c10 = splitc10.join("");
    	
    	c12= $('#txt_annual_visa_sales').val();    	
    	var splitc12= c12.split(',');
    	c12 = splitc12.join("");
    	
    	c128= $('#txt_avr_tic_size').val();    	
    	var splitc128= c128.split(',');
    	c128 = splitc128.join("");
    	
    	c14=vendor.roundNumber((parseFloat(c12)*parseFloat(f10)/100)).toFixed(2);
    	c15=vendor.roundNumber((parseFloat(c14)*parseFloat(f5)/100)).toFixed(2);
    	c17=vendor.roundNumber((0.035*30*parseFloat(c14)/365)).toFixed(2);
    	c18=vendor.roundNumber((parseFloat(c14)*0.0004)).toFixed(2);
    	c19=vendor.roundNumber((parseFloat(c15)-parseFloat(c17)-parseFloat(c18))).toFixed(2);
    	c21=vendor.roundNumber((parseFloat(c12)*parseFloat(f11)/100)).toFixed(2);
    	c22=vendor.roundNumber((parseFloat(c21)*parseFloat(f13)/100)).toFixed(2);
    	c23=vendor.roundNumber((parseFloat(c21)-parseFloat(c22))).toFixed(2);
    	c24=vendor.roundNumber((parseFloat(c21)*parseFloat(f6)/100)).toFixed(2);
    	c26=vendor.roundNumber((parseFloat(c22)*parseFloat(f16)/100)).toFixed(2);
    	c27=vendor.roundNumber((parseFloat(c23)*parseFloat(f17)/100)).toFixed(2);
    	c28=vendor.roundNumber((parseFloat(c21)*0.0007)).toFixed(2);
    	c29=vendor.roundNumber((parseFloat(c22)/parseFloat(c128)*0.0233)).toFixed(2);
    	c30=vendor.roundNumber((parseFloat(c23)/parseFloat(c128)*0.264)).toFixed(2);
    	c31=vendor.roundNumber((parseFloat(c23)*0.002)).toFixed(2);
    	c32=vendor.roundNumber((parseFloat(c23)*0.004)).toFixed(2);
    	c33=vendor.roundNumber((0.035*3*parseFloat(c21)/365)).toFixed(2);
    	c34=vendor.roundNumber((parseFloat(c26)+parseFloat(c27)+parseFloat(c28)+parseFloat(c29)+parseFloat(c30)+parseFloat(c31)+parseFloat(c32)+parseFloat(c33))).toFixed(2);
    	c35=vendor.roundNumber((parseFloat(c24)-parseFloat(c34))).toFixed(2);
    	c37=vendor.roundNumber((parseFloat(c35)+parseFloat(c19))).toFixed(2);
    	c39=vendor.roundNumber((parseFloat(c10)*parseFloat(f9)/100)).toFixed(2);
    	c41=vendor.roundNumber((parseFloat(c39)*0.1)).toFixed(2);
    	c42=vendor.roundNumber((parseFloat(c41)*parseFloat(f5)/100)).toFixed(2);
    	c44=vendor.roundNumber((0.035*30*parseFloat(c41)/365)).toFixed(2);
    	c45=vendor.roundNumber((parseFloat(c41)*0.0006)).toFixed(2);
    	c46=vendor.roundNumber((parseFloat(c42)-parseFloat(c44)-parseFloat(c45))).toFixed(2);
    	c48=vendor.roundNumber((parseFloat(c39)*0.9)).toFixed(2);
    	c49=vendor.roundNumber((parseFloat(c48)*parseFloat(f13)/100)).toFixed(2);
    	c50=vendor.roundNumber((parseFloat(c48)*parseFloat(f12)/100)).toFixed(2);
    	c51=vendor.roundNumber((parseFloat(c48)*parseFloat(f6)/100)).toFixed(2);
    	c53=vendor.roundNumber((parseFloat(c49)*parseFloat(f18)/100)).toFixed(2);
    	c54=vendor.roundNumber((parseFloat(c50)*parseFloat(f19)/100)).toFixed(2);
    	c55=vendor.roundNumber((parseFloat(c49)*0.0002)).toFixed(2);
    	c56=vendor.roundNumber((parseFloat(c50)*0.00184)).toFixed(2);
    	c57=vendor.roundNumber((parseFloat(c49)/parseFloat(c128)*0.0155)).toFixed(2);
    	c58=vendor.roundNumber((parseFloat(c50)/parseFloat(c128)*0.0155)).toFixed(2);
    	c59=vendor.roundNumber((parseFloat(c49)/parseFloat(c128)*0.109)).toFixed(2);
    	c60=vendor.roundNumber((parseFloat(c50)/parseFloat(c128)*0.2635)).toFixed(2);
    	c61=vendor.roundNumber((0.035*3*parseFloat(c48)/365)).toFixed(2);
    	c62=vendor.roundNumber((parseFloat(c53)+parseFloat(c54)+parseFloat(c55)+parseFloat(c56)+parseFloat(c57)+parseFloat(c58)+parseFloat(c59)+parseFloat(c60)+parseFloat(c61))).toFixed(2);
    	c63=vendor.roundNumber((parseFloat(c51)-parseFloat(c62))).toFixed(2);
    	c64=vendor.roundNumber((parseFloat(c63)+parseFloat(c46))).toFixed(2);
    	c66=vendor.roundNumber((parseFloat(c10)*0.1)).toFixed(2);
    	
    	c68=vendor.roundNumber((parseFloat(c66)*parseFloat(f68)/100)).toFixed(2);
    	c69=vendor.roundNumber((parseFloat(c68)*parseFloat(f67)/100)).toFixed(2);
    	c71=vendor.roundNumber((0.035*30*parseFloat(c68)/365)).toFixed(2);
    	c72=vendor.roundNumber((parseFloat(c68)*0.0058)).toFixed(2);
    	c73=vendor.roundNumber((parseFloat(c69)-parseFloat(c71)-parseFloat(c72))).toFixed(2);
    	c75=vendor.roundNumber((parseFloat(c66)*parseFloat(f69)/100)).toFixed(2);
    	c76=vendor.roundNumber((parseFloat(c75)*parseFloat(f67)/100)).toFixed(2);
    	c79=vendor.roundNumber((parseFloat(c75)*parseFloat(f71)/100)).toFixed(2);
    	c80=vendor.roundNumber((0.035*(3-parseFloat(f70))*parseFloat(c75)/365)).toFixed(2);
    	c81=vendor.roundNumber((parseFloat(c75)*0.0029)).toFixed(2);
    	c82=vendor.roundNumber((parseFloat(c76)-parseFloat(c79)-parseFloat(c80)-parseFloat(c81))).toFixed(2);
    	c84=vendor.roundNumber((parseFloat(c73)+parseFloat(c82))).toFixed(2);
    	c87=vendor.roundNumber((parseFloat(c64)+parseFloat(c37)+parseFloat(c84))).toFixed(2);
    	
    	c89=vendor.roundNumber((parseFloat(c10)*0.1)).toFixed(2);
    	c90=vendor.roundNumber((parseFloat(c89)*(parseFloat(f89)/100))).toFixed(2);
    	c91=vendor.roundNumber((parseFloat(c90)*(parseFloat(f88)/100))).toFixed(2);
    	c92=vendor.roundNumber((parseFloat(c90)/parseFloat(c128)*0.05)).toFixed(2);
    	c93=vendor.roundNumber((parseFloat(c91)-parseFloat(c92))).toFixed(2);
    	c94=vendor.roundNumber((parseFloat(c89)*parseFloat(f90)/100)).toFixed(2);
    	c95=vendor.roundNumber((parseFloat(c94)*parseFloat(f88)/100)).toFixed(2);
    	c96=vendor.roundNumber((parseFloat(c94)*0.0015)).toFixed(2);
    	c97=vendor.roundNumber((parseFloat(c94)*0.004)).toFixed(2);
    	c98=vendor.roundNumber((parseFloat(c95)-parseFloat(c96)-parseFloat(c97))).toFixed(2);
    	c99=vendor.roundNumber((parseFloat(c98)+parseFloat(c93))).toFixed(2);
    	c101=vendor.roundNumber((parseFloat(c87)+parseFloat(c99))).toFixed(2);
    	
    	c119=vendor.roundNumber((parseFloat(c101)-parseFloat(c117))).toFixed(2);
    	c120=vendor.roundNumber((parseFloat(c119)*0.75)).toFixed(2);
    	c137=vendor.roundNumber((parseFloat(c15)-parseFloat(c17)+parseFloat(c24)-parseFloat(c26)-parseFloat(c27)-parseFloat(c33)+parseFloat(c42)-parseFloat(c44)+parseFloat(c51)-parseFloat(c53)-parseFloat(c54)-parseFloat(c61)+parseFloat(c69)-parseFloat(c71)+parseFloat(c76)-parseFloat(c79)-parseFloat(c80)+parseFloat(c91)+parseFloat(c95)-parseFloat(c97))).toFixed(2);
    	c143=vendor.roundNumber((parseFloat(c137)*0.15*12.5)).toFixed(2);
    	c144=vendor.roundNumber((parseFloat(c143)*0.13)).toFixed(2);
    	c145=vendor.roundNumber((parseFloat(c144)*0.4)).toFixed(2);
    	c120=vendor.roundNumber((parseFloat(c119)*0.75)).toFixed(2);
    	c121=vendor.roundNumber((parseFloat(c145)*0.04)).toFixed(2);
    	c122=vendor.roundNumber((parseFloat(c120)-parseFloat(c121))).toFixed(2);
    	c146=vendor.roundNumber((parseFloat(c144)*0.6)).toFixed(2);
    	c123=vendor.roundNumber((parseFloat(c146)*0.11)).toFixed(2);
    	c124=vendor.roundNumber((parseFloat(c122)-parseFloat(c123))).toFixed(2);
    	c127=vendor.roundNumber((parseFloat(c9))).toFixed(2);
    	c126=vendor.roundNumber((parseFloat(c127)/parseFloat(c128))).toFixed(2);
    	if(parseFloat(c9)>0) c129=vendor.roundNumber((parseFloat(c119)/parseFloat(c9))).toFixed(2);
    	if(parseFloat(c12)>0) c130=vendor.roundNumber((parseFloat(c37)/parseFloat(c12))).toFixed(2);
    	if(parseFloat(c39)>0) c131=vendor.roundNumber((parseFloat(c64)/parseFloat(c39))).toFixed(2);
    	c136=vendor.roundNumber((parseFloat(c18)+parseFloat(c28)+parseFloat(c29)+parseFloat(c30)+parseFloat(c31)+parseFloat(c32)+parseFloat(c45)+parseFloat(c55)+parseFloat(c56)+parseFloat(c57)+parseFloat(c58)+parseFloat(c59)+parseFloat(c60)+parseFloat(c72)+parseFloat(c81)+parseFloat(c92)+parseFloat(c96)+parseFloat(c106)+parseFloat(c107)+parseFloat(c108)+parseFloat(c109)+parseFloat(c110)+parseFloat(c111)+parseFloat(c112)+parseFloat(c113))).toFixed(2);//c136=vendor.roundNumber((parseFloat(c18)+parseFloat(c28)+parseFloat(c29)+parseFloat(c30)+parseFloat(c31)+parseFloat(c325)+parseFloat(c45)+parseFloat(c55)+parseFloat(c56)+parseFloat(c57)+parseFloat(c58)+parseFloat(c598)+parseFloat(c60)+parseFloat(c72)+parseFloat(c81)+parseFloat(c92)+parseFloat(c96)+parseFloat(c106)+parseFloat(c107)+parseFloat(c108)+parseFloat(c109)+parseFloat(c110)+parseFloat(c111)+parseFloat(c112)+parseFloat(c113))).toFixed(2);
    	if(parseFloat(c137)>0) c138=vendor.roundNumber((parseFloat(c136)/parseFloat(c137))).toFixed(2);
    	if(parseFloat(c143)>0) c139=vendor.roundNumber((parseFloat(c119)/parseFloat(c143))).toFixed(2);
    	if(parseFloat(c144)>0) c141=vendor.roundNumber((parseFloat(c120)/parseFloat(c144))).toFixed(2);
    	if(parseFloat(c66)>0) c132=vendor.roundNumber((parseFloat(c84)/parseFloat(c66))).toFixed(2);
    	if(parseFloat(c146)>0) c140=vendor.roundNumber((parseFloat(c122)/parseFloat(c146))).toFixed(2);
    	/*
    	*/
    	//Display result in respective boxes
    	$('#txt_visa_on_us_card_usage').val(c14.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_gross_on_us_revenue').val(c15.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_cost_fund1').val(c17.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_quarter_fee1').val(c18.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_on_us_visa_nett_earning').val(c19.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_not_on_us_card_usage').val(c21.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_local_not_on_us').val(c22.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_foreign_not_on_us').val(c23.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_gross_not_on_us_revenue').val(c24.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_interchange_fee_local').val(c26.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_interchange_fee_foreign').val(c27.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_quarter_fee2').val(c28.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_base2_charge_local').val(c29.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_base2_charge_foreign').val(c30.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_int_out_fee').val(c31.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_isa_fee').val(c32.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_cost_fund2').val(c33.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_visa_cost_not_on_us_card_usage').val(c34.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_nett_earning_not_on_us_visa').val(c35.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_earning_visa_aqbs').val(c37.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_annual_mc_sales').val(c39.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_on_us_card_usage').val(c41.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_gross_on_us_rev').val(c42.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_cost_fund1').val(c44.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_quarter_fee3').val(c45.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_nett_earn_on_us_mc').val(c46.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_not_on_us_card_usage').val(c48.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_local_not_on_us').val(c49.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_foreign_not_on_us').val(c50.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_gross_not_on_us_rev').val(c51.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_int_fee_local').val(c53.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_int_fee_foreign').val(c54.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_local_outgoing_fee').val(c55.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_int_outgoing_fee').val(c56.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_base1_local_charge').val(c57.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_base1_foreign_charge').val(c58.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_base2_local_charge').val(c59.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_base2_foreign_charge').val(c60.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_cost_fund2').val(c61.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mc_cost_not_on_us_card_usage').val(c62.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_nett_earning_not_on_us_mc').val(c63.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_earning_mc_aqbs').val(c64.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_sales').val(c66.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	
    	$('#txt_amex_on_us_card_usage').val(c68.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_gross_rev').val(c69.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_cost_of_fund1').val(c71.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_royalty_fee1').val(c72.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_net_earning').val(c73.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_not_on_us_card_usage').val(c75.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_gross_not_on_us_rev').val(c76.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_interchange_fee').val(c79.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_cost_of_fund2').val(c80.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_royalty_fee2').val(c81.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_net_erarning_not_on_us').val(c82.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amex_total_gross_aqbs').val(c84.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_gross_visamcamex').val(c87.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	    	
    	$('#txt_debit_projected_sales').val(c89.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_kwnku_epos').val(c90.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_gross_earning_epos').val(c91.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_less_computer_time').val(c92.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_earning_kwnku_epos').val(c93.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_meps_epos').val(c94.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_gross_earning_meps_epos').val(c95.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_less_switching_fee').val(c96.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_less_issuing_fee').val(c97.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_earning_meps_epos').val(c98.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debit_nett_earning').val(c99.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_sub_total_revenue').val(c101.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	$('#txt_equity').val(c146.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_no_transaction').val(c126.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_sales_volume').val(c127.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rocc_sales').val(c129.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rov_sales').val(c130.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_romc_sales').val(c131.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	
    	$('#txt_roamex_sales').val(c132.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_no_mbbedc_terminal').val(c133.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_terminal_cost_edc_permonth').val(c134.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_cost').val(c136.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_income').val(c137.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa').val(c139.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	$('#txt_cost_income').val(c138.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_row').val(c140.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce').val(c141.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cost_equity').val(c123.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_economic_profit').val(c124.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	
    	$('#txt_net_profit').val(c119.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_net_profit_after_tax').val(c120.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_total_income').val(c137.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa').val(c143.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capital_allocated').val(c144.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt').val(c145.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cost_debt').val(c121.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_profit_after_taxcostdebt').val(c122.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_equity').val(c146.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_net_profit_after_tax').val(C120.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	

    	/*
    	$('#txt_avr_tic_size').val(c128.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	*/
    	//CALCULATION END HERE
    },
    
    calculate2 : function(){
    	var b6=0,c6=0,d6=0,e6=0,f6=0,g6=0,h6=0;
    	var b7=0,b8=0,b12=0,b14=0,b16=0,b17=0,b18=0,b19=0,b20=0,b21=0,b23=0,b25=0,b26=0,b27=0,b28=0,b29=0,b30=0,b32=0,b34=0,b35=0,b37=0,b38=0,b39=0,b41=0,b43=0,b44=0,b45=0,b46=0,b47=0,b50=0,b51=0,b52=0,b53=0,b54=0,b55=0,b56=0,b57=0,b58=0,b59=0,b61=0,b62=0,b63,b64=0;
    	var c7=0,c8=0,c12=0,c14=0,c16=0,c17=0,c18=0,c19=0,c20=0,c21=0,c23=0,c25=0,c26=0,c27=0,c28=0,c29=0,c30=0,c32=0,c34=0,c35=0,c37=0,c38=0,c39=0,c41=0,c43=0,c44=0,c45=0,c46=0,c47=0,c50=0,c51=0,c52=0,c53=0,c54=0,c55=0,c56=0,c57=0,c58=0,c59=0,c61=0,c62=0,c63,c64=0;
    	var d7=0,d8=0,d12=0,d14=0,d16=0,d17=0,d18=0,d19=0,d20=0,d21=0,d23=0,d25=0,d26=0,d27=0,d28=0,d29=0,d30=0,d32=0,d34=0,d35=0,d37=0,d38=0,d39=0,d41=0,d43=0,d44=0,d45=0,d46=0,d47=0,d50=0,d51=0,d52=0,d53=0,d54=0,d55=0,d56=0,d57=0,d58=0,d59=0,d61=0,d62=0,d63,d64=0;
    	var e7=0,e8=0,e12=0,e14=0,e16=0,e17=0,e18=0,e19=0,e20=0,e21=0,e23=0,e25=0,e26=0,e27=0,e28=0,e29=0,e30=0,e32=0,e34=0,e35=0,e37=0,e38=0,e39=0,e41=0,e43=0,e44=0,e45=0,e46=0,e47=0,e50=0,e51=0,e52=0,e53=0,e54=0,e55=0,e56=0,e57=0,e58=0,e59=0,e61=0,e62=0,e63,e64=0;
    	var f7=0,f8=0,f12=0,f14=0,f16=0,f17=0,f18=0,f19=0,f20=0,f21=0,f23=0,f25=0,f26=0,f27=0,f28=0,f29=0,f30=0,f32=0,f34=0,f35=0,f37=0,f38=0,f39=0,f41=0,f43=0,f44=0,f45=0,f46=0,f47=0,f50=0,f51=0,f52=0,f53=0,f54=0,f55=0,f56=0,f57=0,f58=0,f59=0,f61=0,f62=0,f63,f64=0;
    	var g7=0,g8=0,g12=0,g14=0,g16=0,g17=0,g18=0,g19=0,g20=0,g21=0,g23=0,g25=0,g26=0,g27=0,g28=0,g29=0,g30=0,g32=0,g34=0,g35=0,g37=0,g38=0,g39=0,g41=0,g43=0,g44=0,g45=0,g46=0,g47=0,g50=0,g51=0,g52=0,g53=0,g54=0,g55=0,g56=0,g57=0,g58=0,g59=0,g61=0,g62=0,g63,g64=0;
    	var h8=0,h12=0,h14=0,h16=0,h17=0,h18=0,h19=0,h20=0,h21=0,h23=0,h25=0,h26=0,h27=0,h28=0,h29=0,h30=0,h32=0,h34=0,h35=0,h37=0,h38=0,h39=0,h41=0,h43=0,h44=0,h45=0,h46=0,h47=0,h50=0,h51=0,h52=0,h53=0,h54=0,h55=0,h56=0,h57=0,h58=0,h59=0,h61=0,h62=0,h63,h64=0;
    	var j11=0,j12=0;
    	
    	if($('#txt_visa').val().length>0  && parseFloat($('#txt_visa').val())<=100){
	    	var result = 100-vendor.roundNumber(parseFloat($('#txt_visa').val()));
	    	$('#txt_mc').val(result.toFixed(2));//.toFixed(2));
    	}
    	else{
    		if(parseFloat($('#txt_visa').val())>100){
    			mapUI.jq_message("Visa percentage cannot be more than 100%", 3);
    			$('#txt_visa').val('0');
    		}
    		if($('#txt_visa').val()==''){
    			$('#txt_visa').val('0');
    		}
    			
    		$('#txt_mc').val('');
    		vendor.calculate2();
    	}
    	
    	if($('#txt_ezy6').val()=="") $('#txt_ezy6').val('0');
    	if($('#txt_ezy12').val()=="") $('#txt_ezy12').val('0');
    	if($('#txt_ezy18').val()=="") $('#txt_ezy18').val('0');
    	if($('#txt_ezy24').val()=="") $('#txt_ezy24').val('0');
    	if($('#txt_ezy30').val()=="") $('#txt_ezy30').val('0');
    	if($('#txt_ezy36').val()=="") $('#txt_ezy36').val('0');
    	
    	if($('#txt_vmcsales6').val()=="") $('#txt_vmcsales6').val('0');
    	if($('#txt_vmcsales12').val()=="") $('#txt_vmcsales12').val('0');
    	if($('#txt_vmcsales18').val()=="") $('#txt_vmcsales18').val('0');
    	if($('#txt_vmcsales24').val()=="") $('#txt_vmcsales24').val('0');
    	if($('#txt_vmcsales30').val()=="") $('#txt_vmcsales30').val('0');
    	if($('#txt_vmcsales36').val()=="") $('#txt_vmcsales36').val('0');
    	if($('#txt_vmcsalest').val()=="") $('#txt_vmcsalest').val('0');
    	
    	if($('#txt_asales6').val()=="") $('#txt_asales6').val('0');
    	if($('#txt_asales12').val()=="") $('#txt_asales12').val('0');
    	if($('#txt_asales18').val()=="") $('#txt_asales18').val('0');
    	if($('#txt_asales24').val()=="") $('#txt_asales24').val('0');
    	if($('#txt_asales30').val()=="") $('#txt_asales30').val('0');
    	if($('#txt_asales36').val()=="") $('#txt_asales36').val('0');
    	if($('#txt_asalest').val()=="") $('#txt_asalest').val('0');
    	
    	//calculation start here
    	$('#txt_mdr6').val().length>0 ? b6= parseFloat($('#txt_mdr6').val()) : b6="0";
    	$('#txt_mdr12').val().length>0 ? c6= parseFloat($('#txt_mdr12').val()) : c6="0";
    	$('#txt_mdr18').val().length>0 ? d6= parseFloat($('#txt_mdr18').val()) : d6="0";
    	$('#txt_mdr24').val().length>0 ? e6= parseFloat($('#txt_mdr24').val()) : e6="0";
    	$('#txt_mdr30').val().length>0 ? f6= parseFloat($('#txt_mdr30').val()) : f6="0";
    	$('#txt_mdr36').val().length>0 ? g6= parseFloat($('#txt_mdr36').val()) : g6="0";
    	
    	$('#txt_ezy6').val().length>0 ? b7= parseFloat($('#txt_ezy6').val()) : b7="0";
    	$('#txt_ezy12').val().length>0 ? c7= parseFloat($('#txt_ezy12').val()) : c7="0";
    	$('#txt_ezy18').val().length>0 ? d7= parseFloat($('#txt_ezy18').val()) : d7="0";
    	$('#txt_ezy24').val().length>0 ? e7= parseFloat($('#txt_ezy24').val()) : e7="0";
    	$('#txt_ezy30').val().length>0 ? f7= parseFloat($('#txt_ezy30').val()) : f7="0";
    	$('#txt_ezy36').val().length>0 ? g7= parseFloat($('#txt_ezy36').val()) : g7="0";
    	
    	$('#txt_vmcsales6').val().length>0 ? b12= parseFloat($('#txt_vmcsales6').val()) : b12="0";
    	$('#txt_vmcsales12').val().length>0 ? c12= parseFloat($('#txt_vmcsales12').val()) : c12="0";
    	$('#txt_vmcsales18').val().length>0 ? d12= parseFloat($('#txt_vmcsales18').val()) : d12="0";
    	$('#txt_vmcsales24').val().length>0 ? e12= parseFloat($('#txt_vmcsales24').val()) : e12="0";
    	$('#txt_vmcsales30').val().length>0 ? f12= parseFloat($('#txt_vmcsales30').val()) : f12="0";
    	$('#txt_vmcsales36').val().length>0 ? g12= parseFloat($('#txt_vmcsales36').val()) : g12="0";
    	
    	$('#txt_asales6').val().length>0 ? b32= parseFloat($('#txt_asales6').val()) : b32="0";
    	$('#txt_asales12').val().length>0 ? c32= parseFloat($('#txt_asales12').val()) : c32="0";
    	$('#txt_asales18').val().length>0 ? d32= parseFloat($('#txt_asales18').val()) : d32="0";
    	$('#txt_asales24').val().length>0 ? e32= parseFloat($('#txt_asales24').val()) : e32="0";
    	$('#txt_asales30').val().length>0 ? f32= parseFloat($('#txt_asales30').val()) : f32="0";
    	$('#txt_asales36').val().length>0 ? g32= parseFloat($('#txt_asales36').val()) : g32="0";
    	
    	h12 = vendor.roundNumber(parseFloat(b12)+parseFloat(c12)+parseFloat(d12)+parseFloat(e12)+parseFloat(f12)+parseFloat(g12));
    	h32 = vendor.roundNumber(parseFloat(b32)+parseFloat(c32)+parseFloat(d32)+parseFloat(e32)+parseFloat(f32)+parseFloat(g32));
    	
    	$('#txt_psales6').val().length>0 ? b8= parseFloat($('#txt_psales6').val()) : b8="0";
    	$('#txt_psales12').val().length>0 ? c8= parseFloat($('#txt_psales12').val()) : c8="0";
    	$('#txt_psales18').val().length>0 ? d8= parseFloat($('#txt_psales18').val()) : d8="0";
    	$('#txt_psales24').val().length>0 ? e8= parseFloat($('#txt_psales24').val()) : e8="0";
    	$('#txt_psales30').val().length>0 ? f8= parseFloat($('#txt_psales30').val()) : f8="0";
    	$('#txt_psales36').val().length>0 ? g8= parseFloat($('#txt_psales36').val()) : g8="0";
    	$('#txt_visa').val().length>0 ? j11= parseFloat($('#txt_visa').val()) : j11="0";
    	$('#txt_mc').val().length>0 ? j12= parseFloat($('#txt_mc').val()) : j12="0";
    	
    	b8= vendor.roundNumber(parseFloat(b12)+parseFloat(b32));
    	c8= vendor.roundNumber(parseFloat(c12)+parseFloat(c32));
    	d8= vendor.roundNumber(parseFloat(d12)+parseFloat(d32));
    	e8= vendor.roundNumber(parseFloat(e12)+parseFloat(e32));
    	f8= vendor.roundNumber(parseFloat(f12)+parseFloat(f32));
    	g8= vendor.roundNumber(parseFloat(g12)+parseFloat(g32));
    	
    	h8 = vendor.roundNumber(parseFloat(b8)+parseFloat(c8)+parseFloat(d8)+parseFloat(e8)+parseFloat(f8)+parseFloat(g8));
    	   	
    	$('#txt_vmcsalest').val(h12.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_asalest').val(h32.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	
    	$('#txt_psales6').val(b8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psales12').val(c8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psales18').val(d8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psales24').val(e8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psales30').val(f8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psales36').val(g8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	$('#txt_psalest').val(h8.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));  	  
    	    	
    	//6month
    	b14=vendor.roundNumber(parseFloat(b12)*parseFloat(j11)/100);
    	b16=vendor.roundNumber(parseFloat(b14)*1);
    	b17=vendor.roundNumber(parseFloat(b16)*parseFloat(b6)/100);
    	b19=vendor.roundNumber(parseFloat(b16)*parseFloat(b7)/100);
    	b20=vendor.roundNumber(parseFloat(b16)*0.0004);
    	b21=vendor.roundNumber(parseFloat(b17)-parseFloat(b19)-parseFloat(b20));
    	b23=vendor.roundNumber(parseFloat(b12)*0.4);
    	b25=vendor.roundNumber(parseFloat(b23)*1);
    	b26=vendor.roundNumber(parseFloat(b25)*b6/100);
    	b28=vendor.roundNumber(parseFloat(b25)*b7/100);
    	b29=vendor.roundNumber(parseFloat(b25)*0.0006);
    	b30=vendor.roundNumber(parseFloat(b26)-parseFloat(b28)-parseFloat(b29));
    	b34=vendor.roundNumber(parseFloat(b32));
    	b35=vendor.roundNumber(parseFloat(b34)*parseFloat(b6)/100);
    	b37=vendor.roundNumber(parseFloat(b34)*parseFloat(b7)/100);
    	b38=vendor.roundNumber(parseFloat(b34)*0.0058);
    	b39=vendor.roundNumber(parseFloat(b35)-parseFloat(b37)-parseFloat(b38));
    	b41=vendor.roundNumber(parseFloat(b21)+parseFloat(b30)+parseFloat(b39));
    	b43=vendor.roundNumber(parseFloat(b41)*0.75);
    	if(parseFloat(b8)>0) b50=vendor.roundNumber(parseFloat(b41)/parseFloat(b8)*100);
    	if(parseFloat(b14)>0) b51=vendor.roundNumber(parseFloat(b21)/parseFloat(b14)*100);
    	if(parseFloat(b23)>0) b52=vendor.roundNumber(parseFloat(b30)/parseFloat(b23)*100);
    	if(parseFloat(b32)>0) b53=vendor.roundNumber(parseFloat(b39)/parseFloat(b32)*100);
    	b54=vendor.roundNumber(parseFloat(b20)+parseFloat(b29)+parseFloat(b38));
    	b55=vendor.roundNumber(parseFloat(b17)-parseFloat(b19)+parseFloat(b26)-parseFloat(b28)+parseFloat(b35)-parseFloat(b37));
    	if(parseFloat(b55)>0)  b56=vendor.roundNumber(parseFloat(b54)/parseFloat(b55)*100);
    	b61=vendor.roundNumber((parseFloat(b8)*81.6/100)+(parseFloat(b55)*15/100*12.5));
    	if(parseFloat(b61)>0) b57=vendor.roundNumber((parseFloat(b41)/parseFloat(b61))*2*100);
    	b62=vendor.roundNumber(parseFloat(b61)*13/100);
    	b64=vendor.roundNumber(parseFloat(b62)*60/100);
    	if(parseFloat(b62)>0) b59=vendor.roundNumber((parseFloat(b43)/parseFloat(b62))*2*100);
    	b63=vendor.roundNumber(parseFloat(b62)*40/100);
    	b44=vendor.roundNumber(parseFloat(b63)*0.04);
    	b45=vendor.roundNumber(parseFloat(b43)-parseFloat(b44));
    	b46=vendor.roundNumber(parseFloat(b64)*0.11);
    	b47=vendor.roundNumber(parseFloat(b45)-parseFloat(b46));
    	if(parseFloat(b64)>0) b58=vendor.roundNumber((parseFloat(b45)/parseFloat(b64))*2*100);
    	
    	$('#txt_vsales6').val(b14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus6').val(b16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus6').val(b17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf6').val(b19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf6').val(b20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv6').val(b21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales6').val(b23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus6').val(b25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus6').val(b26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf6').val(b28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf6').val(b29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc6').val(b30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus6').val(b34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus6').val(b35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf6').val(b37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty6').val(b38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta6').val(b39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot6').val(b41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett6').val(b43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt6').val(b44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt6').val(b45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt6').val(b46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon6').val(b47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar6').val(b50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar6').val(b51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar6').val(b52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar6').val(b53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost6').val(b54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc6').val(b55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr6').val(b56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa6').val(b57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe6').val(b58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce6').val(b59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa6').val(b61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall6').val(b62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt6').val(b63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt6').val(b64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	//12month
    	c14=vendor.roundNumber(parseFloat(c12)*parseFloat(j11)/100);
    	c16=vendor.roundNumber(parseFloat(c14)*1);
    	c17=vendor.roundNumber(parseFloat(c16)*parseFloat(c6)/100);
    	c19=vendor.roundNumber(parseFloat(c16)*parseFloat(c7)/100);
    	c20=vendor.roundNumber(parseFloat(c16)*0.0004);
    	c21=vendor.roundNumber(parseFloat(c17)-parseFloat(c19)-parseFloat(c20));
    	c23=vendor.roundNumber(parseFloat(c12)*0.4);
    	c25=vendor.roundNumber(parseFloat(c23)*1);
    	c26=vendor.roundNumber(parseFloat(c25)*c6/100);
    	c28=vendor.roundNumber(parseFloat(c25)*c7/100);
    	c29=vendor.roundNumber(parseFloat(c25)*0.0006);
    	c30=vendor.roundNumber(parseFloat(c26)-parseFloat(c28)-parseFloat(c29));
    	c34=vendor.roundNumber(parseFloat(c32));
    	c35=vendor.roundNumber(parseFloat(c34)*parseFloat(c6)/100);
    	c37=vendor.roundNumber(parseFloat(c34)*parseFloat(c7)/100);
    	c38=vendor.roundNumber(parseFloat(c34)*0.0058);
    	c39=vendor.roundNumber(parseFloat(c35)-parseFloat(c37)-parseFloat(c38));
    	c41=vendor.roundNumber(parseFloat(c21)+parseFloat(c30)+parseFloat(c39));
    	c43=vendor.roundNumber(parseFloat(c41)*0.75);
    	if(parseFloat(c8)>0) c50=vendor.roundNumber(parseFloat(c41)/parseFloat(c8)*100);
    	if(parseFloat(c14)>0) c51=vendor.roundNumber(parseFloat(c21)/parseFloat(c14)*100);
    	if(parseFloat(c23)>0) c52=vendor.roundNumber(parseFloat(c30)/parseFloat(c23)*100);
    	if(parseFloat(c32)>0) c53=vendor.roundNumber(parseFloat(c39)/parseFloat(c32)*100);
    	c54=vendor.roundNumber(parseFloat(c20)+parseFloat(c29)+parseFloat(c38));
    	c55=vendor.roundNumber(parseFloat(c17)-parseFloat(c19)+parseFloat(c26)-parseFloat(c28)+parseFloat(c35)-parseFloat(c37));
    	if(parseFloat(c55)>0) c56=vendor.roundNumber(parseFloat(c54)/parseFloat(c55)*100);
    	c61=vendor.roundNumber((parseFloat(c8)*81.6/100)+(parseFloat(c55)*15/100*12.5));
    	if(parseFloat(c61)>0) c57=vendor.roundNumber((parseFloat(c41)/parseFloat(c61))*100);
    	c62=vendor.roundNumber(parseFloat(c61)*13/100);
    	c64=vendor.roundNumber(parseFloat(c62)*60/100);
    	if(parseFloat(c62)>0) c59=vendor.roundNumber((parseFloat(c43)/parseFloat(c62))*100);
    	c63=vendor.roundNumber(parseFloat(c62)*40/100);
    	c44=vendor.roundNumber(parseFloat(c63)*0.04);
    	c45=vendor.roundNumber(parseFloat(c43)-parseFloat(c44));
    	c46=vendor.roundNumber(parseFloat(c64)*0.11);
    	c47=vendor.roundNumber(parseFloat(c45)-parseFloat(c46));
    	if(parseFloat(c64)>0) c58=vendor.roundNumber((parseFloat(c45)/parseFloat(c64))*100);
    	
    	$('#txt_vsales12').val(c14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus12').val(c16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus12').val(c17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf12').val(c19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf12').val(c20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv12').val(c21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales12').val(c23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus12').val(c25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus12').val(c26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf12').val(c28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf12').val(c29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc12').val(c30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus12').val(c34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus12').val(c35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf12').val(c37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty12').val(c38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta12').val(c39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot12').val(c41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett12').val(c43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt12').val(c44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt12').val(c45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt12').val(c46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon12').val(c47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar12').val(c50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar12').val(c51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar12').val(c52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar12').val(c53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost12').val(c54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc12').val(c55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr12').val(c56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa12').val(c57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe12').val(c58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce12').val(c59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa12').val(c61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall12').val(c62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt12').val(c63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt12').val(c64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	//18month
    	d14=vendor.roundNumber(parseFloat(d12)*parseFloat(j11)/100);
    	d16=vendor.roundNumber(parseFloat(d14)*1);
    	d17=vendor.roundNumber(parseFloat(d16)*parseFloat(d6)/100);
    	d19=vendor.roundNumber(parseFloat(d16)*parseFloat(d7)/100);
    	d20=vendor.roundNumber(parseFloat(d16)*0.0004);
    	d21=vendor.roundNumber(parseFloat(d17)-parseFloat(d19)-parseFloat(d20));
    	d23=vendor.roundNumber(parseFloat(d12)*0.4);
    	d25=vendor.roundNumber(parseFloat(d23)*1);
    	d26=vendor.roundNumber(parseFloat(d25)*d6/100);
    	d28=vendor.roundNumber(parseFloat(d25)*d7/100);
    	d29=vendor.roundNumber(parseFloat(d25)*0.0006);
    	d30=vendor.roundNumber(parseFloat(d26)-parseFloat(d28)-parseFloat(d29));
    	d34=vendor.roundNumber(parseFloat(d32));
    	d35=vendor.roundNumber(parseFloat(d34)*parseFloat(d6)/100);
    	d37=vendor.roundNumber(parseFloat(d34)*parseFloat(d7)/100);
    	d38=vendor.roundNumber(parseFloat(d34)*0.0058);
    	d39=vendor.roundNumber(parseFloat(d35)-parseFloat(d37)-parseFloat(d38));
    	d41=vendor.roundNumber(parseFloat(d21)+parseFloat(d30)+parseFloat(d39));
    	d43=vendor.roundNumber(parseFloat(d41)*0.75);
    	if(parseFloat(d8)>0) d50=vendor.roundNumber(parseFloat(d41)/parseFloat(d8)*100);
    	if(parseFloat(d19)>0) d51=vendor.roundNumber(parseFloat(d21)/parseFloat(d14)*100);
    	if(parseFloat(d23)>0) d52=vendor.roundNumber(parseFloat(d30)/parseFloat(d23)*100);
    	if(parseFloat(d32)>0) d53=vendor.roundNumber(parseFloat(d39)/parseFloat(d32)*100);
    	d54=vendor.roundNumber(parseFloat(d20)+parseFloat(d29)+parseFloat(d38));
    	d55=vendor.roundNumber(parseFloat(d17)-parseFloat(d19)+parseFloat(d26)-parseFloat(d28)+parseFloat(d35)-parseFloat(d37));
    	if(parseFloat(d55)>0) d56=vendor.roundNumber(parseFloat(d54)/parseFloat(d55)*100);
    	d61=vendor.roundNumber((parseFloat(d8)*81.6/100)+(parseFloat(d55)*15/100*12.5));
    	if(parseFloat(d61)>0) d57=vendor.roundNumber((parseFloat(d41)/parseFloat(d61))*100*12/18);
    	d62=vendor.roundNumber(parseFloat(d61)*13/100);
    	d64=vendor.roundNumber(parseFloat(d62)*60/100);
    	if(parseFloat(d62)>0) d59=vendor.roundNumber((parseFloat(d43)/parseFloat(d62))*100*12/18);
    	d63=vendor.roundNumber(parseFloat(d62)*40/100);
    	d44=vendor.roundNumber(parseFloat(d63)*0.04);
    	d45=vendor.roundNumber(parseFloat(d43)-parseFloat(d44));
    	d46=vendor.roundNumber(parseFloat(d64)*0.11);
    	d47=vendor.roundNumber(parseFloat(d45)-parseFloat(d46));
    	if(parseFloat(d64)>0) d58=vendor.roundNumber((parseFloat(d45)/parseFloat(d64))*100*12/18);
    	
    	$('#txt_vsales18').val(d14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus18').val(d16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus18').val(d17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf18').val(d19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf18').val(d20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv18').val(d21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales18').val(d23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus18').val(d25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus18').val(d26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf18').val(d28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf18').val(d29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc18').val(d30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus18').val(d34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus18').val(d35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf18').val(d37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty18').val(d38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta18').val(d39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot18').val(d41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett18').val(d43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt18').val(d44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt18').val(d45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt18').val(d46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon18').val(d47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar18').val(d50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar18').val(d51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar18').val(d52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar18').val(d53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost18').val(d54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc18').val(d55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr18').val(d56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa18').val(d57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe18').val(d58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce18').val(d59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa18').val(d61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall18').val(d62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt18').val(d63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt18').val(d64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	//24month
    	e14=vendor.roundNumber(parseFloat(e12)*parseFloat(j11)/100);
    	e16=vendor.roundNumber(parseFloat(e14)*1);
    	e17=vendor.roundNumber(parseFloat(e16)*parseFloat(e6)/100);
    	e19=vendor.roundNumber(parseFloat(e16)*parseFloat(e7)/100);
    	e20=vendor.roundNumber(parseFloat(e16)*0.0004);
    	e21=vendor.roundNumber(parseFloat(e17)-parseFloat(e19)-parseFloat(e20));
    	e23=vendor.roundNumber(parseFloat(e12)*0.4);
    	e25=vendor.roundNumber(parseFloat(e23)*1);
    	e26=vendor.roundNumber(parseFloat(e25)*e6/100);
    	e28=vendor.roundNumber(parseFloat(e25)*e7/100);
    	e29=vendor.roundNumber(parseFloat(e25)*0.0006);
    	e30=vendor.roundNumber(parseFloat(e26)-parseFloat(e28)-parseFloat(e29));
    	e34=vendor.roundNumber(parseFloat(e32));
    	e35=vendor.roundNumber(parseFloat(e34)*parseFloat(e6)/100);
    	e37=vendor.roundNumber(parseFloat(e34)*parseFloat(e7)/100);
    	e38=vendor.roundNumber(parseFloat(e34)*0.0058);
    	e39=vendor.roundNumber(parseFloat(e35)-parseFloat(e37)-parseFloat(e38));
    	e41=vendor.roundNumber(parseFloat(e21)+parseFloat(e30)+parseFloat(e39));
    	e43=vendor.roundNumber(parseFloat(e41)*0.75);
    	if(parseFloat(e8)>0) e50=vendor.roundNumber(parseFloat(e41)/parseFloat(e8)*100);
    	if(parseFloat(e19)>0) e51=vendor.roundNumber(parseFloat(e21)/parseFloat(e14)*100);
    	if(parseFloat(e23)>0) e52=vendor.roundNumber(parseFloat(e30)/parseFloat(e23)*100);
    	if(parseFloat(e32)>0) e53=vendor.roundNumber(parseFloat(e39)/parseFloat(e32)*100);
    	e54=vendor.roundNumber(parseFloat(e20)+parseFloat(e29)+parseFloat(e38));
    	e55=vendor.roundNumber(parseFloat(e17)-parseFloat(e19)+parseFloat(e26)-parseFloat(e28)+parseFloat(e35)-parseFloat(e37));
    	if(parseFloat(e55)>0) e56=vendor.roundNumber(parseFloat(e54)/parseFloat(e55)*100);
    	e61=vendor.roundNumber((parseFloat(e8)*81.6/100)+(parseFloat(e55)*15/100*12.5));
    	if(parseFloat(e61)>0) e57=vendor.roundNumber((parseFloat(e41)/parseFloat(e61))*100/2);
    	e62=vendor.roundNumber(parseFloat(e61)*13/100);
    	e64=vendor.roundNumber(parseFloat(e62)*60/100);
    	if(parseFloat(e62)>0) e59=vendor.roundNumber((parseFloat(e43)/parseFloat(e62))*100/2);
    	e63=vendor.roundNumber(parseFloat(e62)*40/100);
    	e44=vendor.roundNumber(parseFloat(e63)*0.04);
    	e45=vendor.roundNumber(parseFloat(e43)-parseFloat(e44));
    	e46=vendor.roundNumber(parseFloat(e64)*0.11);
    	e47=vendor.roundNumber(parseFloat(e45)-parseFloat(e46));
    	if(parseFloat(e64)>0) e58=vendor.roundNumber((parseFloat(e45)/parseFloat(e64))*100/2);
    	$('#txt_vsales24').val(e14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus24').val(e16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus24').val(e17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf24').val(e19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf24').val(e20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv24').val(e21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales24').val(e23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus24').val(e25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus24').val(e26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf24').val(e28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf24').val(e29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc24').val(e30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus24').val(e34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus24').val(e35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf24').val(e37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty24').val(e38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta24').val(e39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot24').val(e41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett24').val(e43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt24').val(e44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt24').val(e45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt24').val(e46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon24').val(e47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar24').val(e50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar24').val(e51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar24').val(e52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar24').val(e53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost24').val(e54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc24').val(e55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr24').val(e56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa24').val(e57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe24').val(e58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce24').val(e59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa24').val(e61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall24').val(e62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt24').val(e63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt24').val(e64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	//30month
    	f14=vendor.roundNumber(parseFloat(f12)*parseFloat(j11)/100);
    	f16=vendor.roundNumber(parseFloat(f14)*1);
    	f17=vendor.roundNumber(parseFloat(f16)*parseFloat(f6)/100);
    	f19=vendor.roundNumber(parseFloat(f16)*parseFloat(f7)/100);
    	f20=vendor.roundNumber(parseFloat(f16)*0.0004);
    	f21=vendor.roundNumber(parseFloat(f17)-parseFloat(f19)-parseFloat(f20));
    	f23=vendor.roundNumber(parseFloat(f12)*0.4);
    	f25=vendor.roundNumber(parseFloat(f23)*1);
    	f26=vendor.roundNumber(parseFloat(f25)*f6/100);
    	f28=vendor.roundNumber(parseFloat(f25)*f7/100);
    	f29=vendor.roundNumber(parseFloat(f25)*0.0006);
    	f30=vendor.roundNumber(parseFloat(f26)-parseFloat(f28)-parseFloat(f29));
    	f34=vendor.roundNumber(parseFloat(f32));
    	f35=vendor.roundNumber(parseFloat(f34)*parseFloat(f6)/100);
    	f37=vendor.roundNumber(parseFloat(f34)*parseFloat(f7)/100);
    	f38=vendor.roundNumber(parseFloat(f34)*0.0058);
    	f39=vendor.roundNumber(parseFloat(f35)-parseFloat(f37)-parseFloat(f38));
    	f41=vendor.roundNumber(parseFloat(f21)+parseFloat(f30)+parseFloat(f39));
    	f43=vendor.roundNumber(parseFloat(f41)*0.75);
    	if(parseFloat(f8)>0) f50=vendor.roundNumber(parseFloat(f41)/parseFloat(f8)*100);
    	if(parseFloat(f19)>0) f51=vendor.roundNumber(parseFloat(f21)/parseFloat(f14)*100);
    	if(parseFloat(f23)>0) f52=vendor.roundNumber(parseFloat(f30)/parseFloat(f23)*100);
    	if(parseFloat(f32)>0) f53=vendor.roundNumber(parseFloat(f39)/parseFloat(f32)*100);
    	f54=vendor.roundNumber(parseFloat(f20)+parseFloat(f29)+parseFloat(f38));
    	f55=vendor.roundNumber(parseFloat(f17)-parseFloat(f19)+parseFloat(f26)-parseFloat(f28)+parseFloat(f35)-parseFloat(f37));
    	if(parseFloat(f55)>0) f56=vendor.roundNumber(parseFloat(f54)/parseFloat(f55)*100);
    	f61=vendor.roundNumber((parseFloat(f8)*81.6/100)+(parseFloat(f55)*15/100*12.5));
    	if(parseFloat(f61)>0) f57=vendor.roundNumber((parseFloat(f41)/parseFloat(f61))*100*12/30);
    	f62=vendor.roundNumber(parseFloat(f61)*13/100);
    	f64=vendor.roundNumber(parseFloat(f62)*60/100);
    	if(parseFloat(f62)>0) f59=vendor.roundNumber((parseFloat(f43)/parseFloat(f62))*100*12/30);
    	f63=vendor.roundNumber(parseFloat(f62)*40/100);
    	f44=vendor.roundNumber(parseFloat(f63)*0.04);
    	f45=vendor.roundNumber(parseFloat(f43)-parseFloat(f44));
    	f46=vendor.roundNumber(parseFloat(f64)*0.11);
    	f47=vendor.roundNumber(parseFloat(f45)-parseFloat(f46));
    	if(parseFloat(f64)>0) f58=vendor.roundNumber((parseFloat(f45)/parseFloat(f64))*100*12/30);
    	
    	$('#txt_vsales30').val(f14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus30').val(f16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus30').val(f17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf30').val(f19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf30').val(f20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv30').val(f21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales30').val(f23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus30').val(f25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus30').val(f26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf30').val(f28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf30').val(f29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc30').val(f30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus30').val(f34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus30').val(f35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf30').val(f37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty30').val(f38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta30').val(f39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot30').val(f41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett30').val(f43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt30').val(f44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt30').val(f45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt30').val(f46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon30').val(f47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar30').val(f50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar30').val(f51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar30').val(f52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar30').val(f53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost30').val(f54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc30').val(f55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr30').val(f56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa30').val(f57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe30').val(f58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce30').val(f59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa30').val(f61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall30').val(f62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt30').val(f63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt30').val(f64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	
    	//36month
    	g14=vendor.roundNumber(parseFloat(g12)*parseFloat(j11)/100);
    	g16=vendor.roundNumber(parseFloat(g14)*1);
    	g17=vendor.roundNumber(parseFloat(g16)*parseFloat(g6)/100);
    	g19=vendor.roundNumber(parseFloat(g16)*parseFloat(g7)/100);
    	g20=vendor.roundNumber(parseFloat(g16)*0.0004);
    	g21=vendor.roundNumber(parseFloat(g17)-parseFloat(g19)-parseFloat(g20));
    	g23=vendor.roundNumber(parseFloat(g12)*0.4);
    	g25=vendor.roundNumber(parseFloat(g23)*1);
    	g26=vendor.roundNumber(parseFloat(g25)*g6/100);
    	g28=vendor.roundNumber(parseFloat(g25)*g7/100);
    	g29=vendor.roundNumber(parseFloat(g25)*0.0006);
    	g30=vendor.roundNumber(parseFloat(g26)-parseFloat(g28)-parseFloat(g29));
    	g34=vendor.roundNumber(parseFloat(g32));
    	g35=vendor.roundNumber(parseFloat(g34)*parseFloat(g6)/100);
    	g37=vendor.roundNumber(parseFloat(g34)*parseFloat(g7)/100);
    	g38=vendor.roundNumber(parseFloat(g34)*0.0058);
    	g39=vendor.roundNumber(parseFloat(g35)-parseFloat(g37)-parseFloat(g38));
    	g41=vendor.roundNumber(parseFloat(g21)+parseFloat(g30)+parseFloat(g39));
    	g43=vendor.roundNumber(parseFloat(g41)*0.75);
    	if(parseFloat(g8)>0) g50=vendor.roundNumber(parseFloat(g41)/parseFloat(g8)*100);
    	if(parseFloat(g19)>0) g51=vendor.roundNumber(parseFloat(g21)/parseFloat(g14)*100);
    	if(parseFloat(g23)>0) g52=vendor.roundNumber(parseFloat(g30)/parseFloat(g23)*100);
    	if(parseFloat(g32)>0) g53=vendor.roundNumber(parseFloat(g39)/parseFloat(g32)*100);
    	g54=vendor.roundNumber(parseFloat(g20)+parseFloat(g29)+parseFloat(g38));
    	g55=vendor.roundNumber(parseFloat(g17)-parseFloat(g19)+parseFloat(g26)-parseFloat(g28)+parseFloat(g35)-parseFloat(g37));
    	if(parseFloat(g55)>0) g56=vendor.roundNumber(parseFloat(g54)/parseFloat(g55)*100);
    	g61=vendor.roundNumber((parseFloat(g8)*81.6/100)+(parseFloat(g55)*15/100*12.5));
    	if(parseFloat(g61)>0) g57=vendor.roundNumber((parseFloat(g41)/parseFloat(g61))*100/3);
    	g62=vendor.roundNumber(parseFloat(g61)*13/100);
    	g64=vendor.roundNumber(parseFloat(g62)*60/100);
    	if(parseFloat(g62)>0) g59=vendor.roundNumber((parseFloat(g43)/parseFloat(g62))*100/3);
    	g63=vendor.roundNumber(parseFloat(g62)*40/100);
    	g44=vendor.roundNumber(parseFloat(g63)*0.04);
    	g45=vendor.roundNumber(parseFloat(g43)-parseFloat(g44));
    	g46=vendor.roundNumber(parseFloat(g64)*0.11);
    	g47=vendor.roundNumber(parseFloat(g45)-parseFloat(g46));
    	if(parseFloat(g64)>0) g58=vendor.roundNumber((parseFloat(g45)/parseFloat(g64))*100/3);
    	$('#txt_vsales36').val(g14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonus36').val(g16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonus36').val(g17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostf36').val(g19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarf36').val(g20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettv36').val(g21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsales36').val(g23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconus36').val(g25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconus36').val(g26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostf36').val(g28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarf36').val(g29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmc36').val(g30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonus36').val(g34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonus36').val(g35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostf36').val(g37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyalty36').val(g38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anetta36').val(g39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatot36').val(g41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcanett36').val(g43.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcadebt36').val(g44.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcataxdebt36').val(g45.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaeqt36').val(g46.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcaecon36').val(g47.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmar36').val(g50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmar36').val(g51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmar36').val(g52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amar36').val(g53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcost36').val(g54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinc36').val(g55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincr36').val(g56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rrwa36').val(g57.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roe36').val(g58.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_roce36').val(g59.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_rwa36').val(g61.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_capall36').val(g62.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_debt36').val(g63.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_eqt36').val(g64.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    	//total
    	h14=vendor.roundNumber(parseFloat(b14)+parseFloat(c14)+parseFloat(d14)+parseFloat(e14)+parseFloat(f14)+parseFloat(g14));
    	h16=vendor.roundNumber(parseFloat(b16)+parseFloat(c16)+parseFloat(d16)+parseFloat(e16)+parseFloat(f16)+parseFloat(g16));
    	h17=vendor.roundNumber(parseFloat(b17)+parseFloat(c17)+parseFloat(d17)+parseFloat(e17)+parseFloat(f17)+parseFloat(g17));
    	h19=vendor.roundNumber(parseFloat(b19)+parseFloat(c19)+parseFloat(d19)+parseFloat(e19)+parseFloat(f19)+parseFloat(g19));
    	h20=vendor.roundNumber(parseFloat(b20)+parseFloat(c20)+parseFloat(d20)+parseFloat(e20)+parseFloat(f20)+parseFloat(g20));
    	h21=vendor.roundNumber(parseFloat(b21)+parseFloat(c21)+parseFloat(d21)+parseFloat(e21)+parseFloat(f21)+parseFloat(g21));
    	h23=vendor.roundNumber(parseFloat(b23)+parseFloat(c23)+parseFloat(d23)+parseFloat(e23)+parseFloat(f23)+parseFloat(g23));
    	h25=vendor.roundNumber(parseFloat(b25)+parseFloat(c25)+parseFloat(d25)+parseFloat(e25)+parseFloat(f25)+parseFloat(g25));
    	h26=vendor.roundNumber(parseFloat(b26)+parseFloat(c26)+parseFloat(d26)+parseFloat(e26)+parseFloat(f26)+parseFloat(g26));
    	h28=vendor.roundNumber(parseFloat(b28)+parseFloat(c28)+parseFloat(d28)+parseFloat(e28)+parseFloat(f28)+parseFloat(g28));
    	h29=vendor.roundNumber(parseFloat(b29)+parseFloat(c29)+parseFloat(d29)+parseFloat(e29)+parseFloat(f29)+parseFloat(g29));
    	h30=vendor.roundNumber(parseFloat(b30)+parseFloat(c30)+parseFloat(d30)+parseFloat(e30)+parseFloat(f30)+parseFloat(g30));
    	h34=vendor.roundNumber(parseFloat(b34)+parseFloat(c34)+parseFloat(d34)+parseFloat(e34)+parseFloat(f34)+parseFloat(g34));
    	h35=vendor.roundNumber(parseFloat(b35)+parseFloat(c35)+parseFloat(d35)+parseFloat(e35)+parseFloat(f35)+parseFloat(g35));
    	h37=vendor.roundNumber(parseFloat(b37)+parseFloat(c37)+parseFloat(d37)+parseFloat(e37)+parseFloat(f37)+parseFloat(g37));
    	h38=vendor.roundNumber(parseFloat(b38)+parseFloat(c38)+parseFloat(d38)+parseFloat(e38)+parseFloat(f38)+parseFloat(g38));
    	h39=vendor.roundNumber(parseFloat(b39)+parseFloat(c39)+parseFloat(d39)+parseFloat(e39)+parseFloat(f39)+parseFloat(g39));
    	h41=vendor.roundNumber(parseFloat(b41)+parseFloat(c41)+parseFloat(d41)+parseFloat(e41)+parseFloat(f41)+parseFloat(g41));
    	if(parseFloat(h8)>0) h50=vendor.roundNumber(parseFloat(h41)/parseFloat(h8)*100);
    	if(parseFloat(h19)>0) h51=vendor.roundNumber(parseFloat(h21)/parseFloat(h14)*100);
    	if(parseFloat(h23)>0) h52=vendor.roundNumber(parseFloat(h30)/parseFloat(h23)*100);
    	if(parseFloat(h32)>0) h53=vendor.roundNumber(parseFloat(h39)/parseFloat(h32)*100);
    	h54=vendor.roundNumber(parseFloat(h20)+parseFloat(h29)+parseFloat(h38));
    	h55=vendor.roundNumber(parseFloat(h17)-parseFloat(h19)+parseFloat(h26)-parseFloat(h28)+parseFloat(h35)-parseFloat(h37));
    	if(parseFloat(h55)>0) h56=vendor.roundNumber(parseFloat(h54)/parseFloat(h55)*100);
    	
    	$('#txt_vsalest').val(h14.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vonust').val(h16.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gvonust').val(h17.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vcostft').val(h19.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vquarft').val(h20.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vnettvt').val(h21.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcsalest').val(h23.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mconust').val(h25.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gmconust').val(h26.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mccostft').val(h28.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcquarft').val(h29.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcnettmct').val(h30.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aonust').val(h34.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_gaonust').val(h35.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_acostft').val(h37.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_aroyaltyt').val(h38.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_anettat').val(h39.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmcatott').val(h41.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_netmart').val(h50.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_vmart').val(h51.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_mcmart').val(h52.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_amart').val(h53.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tcostt').val(h54.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_tinct').val(h55.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	$('#txt_cincrt').val(h56.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    	
    },
	
	_create_pos_form : function(merchant_id, case_id, cb) {
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&outlet_id=' + encodeURIComponent(elmt.value);
		
		elmt = document.form.app_no;
		postdata += '&app_no=' + encodeURIComponent(elmt.value);
		
		
		var data = {};
		
		elmt = document.form.request_type;
		if(elmt.value.length <= 0){
			//mapUI.jq_message('Request Type must not be blank.', 10);
			if(typeof cb === 'function'){
				cb();
			}
			
			return;
		}
		data['request_type'] = elmt.value;
		
		
		if(data['request_type'] == 'Tag-on'){
			elmt = document.form.bank;
			data['bank'] = elmt.value;
		}
		else {
			data['bank'] = '';
		}
		
		elmt = document.form.org_code;
		data['org_code'] = elmt.value;

		elmt = document.form.wired_unit_required;
		data['wired_unit_required'] = elmt.value;
		
		elmt = document.form.wireless_unit_required;
		data['wireless_unit_required'] = elmt.value;
		
		elmt = document.form.wireless_terminal_sim_mbb;
		data['wireless_terminal_sim_mbb'] = $(elmt).is(':checked') ? elmt.value : '';
		
		elmt = document.form.wireless_terminal_sim_vendor;
		data['wireless_terminal_sim_vendor'] = $(elmt).is(':checked') ? elmt.value : '';
		
		elmt = document.form.mpos_unit_required;
		data['mpos_unit_required'] = elmt.value;
		
		elmt = document.form.merchant_name;
		data['merchant_name'] = elmt.value;

		elmt = document.form.acc_no;
		data['acc_no'] = elmt.value;
		
		elmt = document.form.merchant_addr;
		data['merchant_addr'] = elmt.value;
		
		elmt = document.form.marchant_pic;
		data['marchant_pic'] = elmt.value;
		
		elmt = document.form.merchant_handphone;
		data['merchant_handphone'] = elmt.value;
		
		
		var vendor_details = {};
		
		var vendor_name = $('div#stock_vendor_detail').children('div.detail').attr('data-name');
		/*if(vendor_name.length <= 0){
			mapUI.jq_message('Please select a vendor.', 10);
			return;
		}*/
		
		if(vendor_name.length > 0){
			vendor_details['name'] = vendor_name;
			
			$('table.generalinfo').children('tbody').children('tr').each(function(index, elmt){
				var td = $(this).children('td:eq(1)');
				
				if($(this).hasClass('serialno')) {
					vendor_details['serial_no'] = td.children('input').val();
				}
				else if($(this).hasClass('vendorname')) {
					vendor_details['name2'] = td.children('select').val();
				}
				else if($(this).hasClass('vendoremail')) {
					vendor_details['email'] = td.children('input').val();
				}
				else if($(this).hasClass('vendorname_other')) {
					vendor_details['name3'] = td.children('input').val();
				}
			});
			
			//var serial_no = '';
			var stock_items = {};
			$('table.stock_items').children('tbody').children('tr').each(function(index, elmt){
				//var serialno_td = $(this).children('td.serialno');
				var wired_td = $(this).children('td.wired');
				var wireless_td = $(this).children('td.wireless');
				var mpos_td = $(this).children('td.mpos');
				
				//serial_no = serialno_td.children('input').val();
				
				stock_items = {
						'wired' : wired_td.children('input').val(),
						'wireless' : wireless_td.children('input').val(),
						'mpos' : mpos_td.children('input').val()
					};
				
			});
			
			//vendor_details['serial_no'] = serial_no;
			vendor_details['stock_items'] = stock_items;
			
			
			var mdr_facilities = {};
			$('table.mdr_facilities').children('tbody').children('tr').each(function(index, elmt){
				var facility_td = $(this).children('td.facility');
				var mid_td = $(this).children('td.mid_no');
				var mid_td2 = $(this).children('td.mid_no2');
				var type_td = $(this).children('td.type');
				var tid_td = $(this).children('td.tid_no');
				var item_td = $(this).children('td.tid_items');
				
				if(facility_td.children('input').val().length > 0){
					var facility_name = facility_td.children('input').val();
					var facility_type = type_td.children('input').val();
					
					if(mdr_facilities[facility_name] == null){
						mdr_facilities[facility_name] = {};
					}
					
					var mdr_facility_type = mdr_facilities[facility_name];
					
					mdr_facility_type[facility_type] = {
							'mid_no' : mid_td.children('input').val(),
							'mid_no2' : mid_td2.children('input').val(),
							'first_tid' : tid_td.children('input').val(),
							'tid_items' : item_td.children('input').val()
						};
					
					mdr_facilities[facility_name] = mdr_facility_type;
				}
			});
			
			vendor_details['mdr_facilities'] = mdr_facilities;
			
			
			var pos_ezypay_facilities = {};
			var pos_ezypay_arr = {};
			
			$('table.pos_ezypay').children('tbody').children('tr').each(function(index, elmt){
				var tid_td = $(this).children('td.tid_no');
				var type_td = $(this).children('td.type');
				var ezypay_plan = $(this).children('td.ezypay_plan');
				var mid_td = $(this).children('td.mid_no');
				var first_td = $(this).children('td.first_tid');
				
				var pos_ezypay_item = {
						'tid_no' : tid_td.children('input').val(),
						'type' : type_td.children('input').val(),
						'ezypay_plan' : ezypay_plan.children('input').val(),
						'mid_no' : mid_td.children('input').val(),
						'first_tid' : first_td.children('input').val()
					};
				
				if(pos_ezypay_facilities[tid_td.children('input').val()] != null) {
					pos_ezypay_arr = pos_ezypay_facilities[tid_td.children('input').val()];
				} else {
					pos_ezypay_arr = {};
				}
				
				pos_ezypay_arr['E' + ezypay_plan.children('input').val()] = pos_ezypay_item
				pos_ezypay_facilities[tid_td.children('input').val()] = pos_ezypay_arr;
			});
			
			vendor_details['pos_ezypay_facilities'] = pos_ezypay_facilities;
			
			
			
			var amex_ezypay_facilities = {};
			var amex_ezypay_arr = {};
			
			$('table.amex_ezypay').children('tbody').children('tr').each(function(index, elmt){
				var tid_td = $(this).children('td.tid_no');
				var type_td = $(this).children('td.type');
				var ezypay_plan = $(this).children('td.ezypay_plan');
				var mid_td = $(this).children('td.mid_no');
				var first_td = $(this).children('td.first_tid');
				var item_td = $(this).children('td.tid_items');
				
				var amex_ezypay_item = {
						'tid_no' : tid_td.children('input').val(),
						'type' : type_td.children('input').val(),
						'ezypay_plan' : ezypay_plan.children('input').val(),
						'mid_no' : mid_td.children('input').val(),
						'first_tid' : first_td.children('input').val()
					};
				
				
				if(amex_ezypay_facilities[tid_td.children('input').val()] != null) {
					amex_ezypay_arr = amex_ezypay_facilities[tid_td.children('input').val()];
				} else {
					amex_ezypay_arr = {};
				}
				
				amex_ezypay_arr['E' + ezypay_plan.children('input').val()] = amex_ezypay_item
				amex_ezypay_facilities[tid_td.children('input').val()] = amex_ezypay_arr;
			});
			
			vendor_details['amex_ezypay_facilities'] = amex_ezypay_facilities;
			
			
			var card_types = [];
			$('table.vendor_card_type').children('tbody').find('td').each(function(index, elmt){
				var checkbox = $(this).children('label').children('input[type=checkbox]');
				if(checkbox.is(':checked')){
					card_types.push(checkbox.val());
				}
			});
			
			vendor_details['card_types'] = card_types;
			
			
			elmt = document.form.diners_select;
			if($(elmt).is(':checked')){
				vendor_details['diners_select'] = $(elmt).val();
				
				elmt = document.form.diners_mid;
				vendor_details['diners_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['diners_select'] = '';
				vendor_details['diners_mid'] = '';
			}
			
			
			elmt = document.form.aeon_select;
			if($(elmt).is(':checked')){
				vendor_details['aeon_select'] = $(elmt).val();
				
				elmt = document.form.aeon_mid;
				vendor_details['aeon_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['aeon_select'] = '';
				vendor_details['aeon_mid'] = '';
			}
			
			
			elmt = document.form.genting_select;
			if($(elmt).is(':checked')){
				vendor_details['genting_select'] = $(elmt).val();
				
				elmt = document.form.genting_mid;
				vendor_details['genting_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['genting_select'] = '';
				vendor_details['genting_mid'] = '';
			}
		}
		
		data['vendor_details'] = vendor_details;
		
		
		
		var edc_programme = [];
		$('table.edc_programme').children('tbody').find('td').each(function(index, elmt){
			var checkbox = $(this).children('label').children('input[type=checkbox]');
			if(checkbox.is(':checked')){
				edc_programme.push(checkbox.val());
			}
		});
		
		data['edc_programme'] = edc_programme;
		
		
		elmt = document.form.inst_remarks;
		data['inst_remarks'] = elmt.value;

		elmt = document.form.mbb_officer;
		data['mbb_officer'] = elmt.value;
		
		elmt = document.form.mbb_officer_handphone;
		data['mbb_officer_handphone'] = elmt.value;
		
		elmt = document.form.trm_rental_wired_amt;
		data['trm_rental_wired_amt'] = elmt.value;

		elmt = document.form.trm_rental_wireless_amt;
		data['trm_rental_wireless_amt'] = elmt.value;
		
		elmt = document.form.trm_deposit_amt;
		data['trm_deposit_amt'] = elmt.value;
		
		
		postdata += "&pos_form=" + encodeURIComponent(JSON.stringify(data));
		
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
            	if(typeof cb === 'function'){
            		cb();
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_pos_form',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	_create_notification : function(merchant_id, case_id, cb) {
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&outlet_id=' + encodeURIComponent(elmt.value);
		
		
		var data = {};
		
		elmt = document.form.request_type;
		if(elmt.value.length <= 0){
			//mapUI.jq_message('Request Type must not be blank.', 10);
			if(typeof cb === 'function'){
				cb();
			}
			
			return;
		}
		data['request_type'] = elmt.value;
		
		
		if(data['request_type'] == 'Tag-on'){
			elmt = document.form.bank;
			data['bank'] = elmt.value;
		}
		else {
			data['bank'] = '';
		}
		
		elmt = document.form.org_code;
		data['org_code'] = elmt.value;

		elmt = document.form.wired_unit_required;
		data['wired_unit_required'] = elmt.value;
		
		elmt = document.form.wireless_unit_required;
		data['wireless_unit_required'] = elmt.value;
		
		elmt = document.form.wireless_terminal_sim_mbb;
		data['wireless_terminal_sim_mbb'] = $(elmt).is(':checked') ? elmt.value : '';
		
		elmt = document.form.wireless_terminal_sim_vendor;
		data['wireless_terminal_sim_vendor'] = $(elmt).is(':checked') ? elmt.value : '';
		
		elmt = document.form.mpos_unit_required;
		data['mpos_unit_required'] = elmt.value;
		
		elmt = document.form.merchant_name;
		data['merchant_name'] = elmt.value;

		elmt = document.form.acc_no;
		data['acc_no'] = elmt.value;
		
		elmt = document.form.merchant_addr;
		data['merchant_addr'] = elmt.value;
		
		elmt = document.form.marchant_pic;
		data['marchant_pic'] = elmt.value;
		
		elmt = document.form.merchant_handphone;
		data['merchant_handphone'] = elmt.value;
		
		
		var vendor_details = {};
		
		var vendor_name = $('div#stock_vendor_detail').children('div.detail').attr('data-name');
		/*if(vendor_name.length <= 0){
			mapUI.jq_message('Please select a vendor.', 10);
			return;
		}*/
		
		if(vendor_name.length > 0){
			vendor_details['name'] = vendor_name;
			
			$('table.generalinfo').children('tbody').children('tr').each(function(index, elmt){
				var td = $(this).children('td:eq(1)');
				
				if($(this).hasClass('serialno')) {
					vendor_details['serial_no'] = td.children('input').val();
				}
				else if($(this).hasClass('vendorname')) {
					vendor_details['name2'] = td.children('select').val();
				}
				else if($(this).hasClass('vendoremail')) {
					vendor_details['email'] = td.children('input').val();
				}
			});
			
			//var serial_no = '';
			var stock_items = {};
			$('table.stock_items').children('tbody').children('tr').each(function(index, elmt){
				//var serialno_td = $(this).children('td.serialno');
				var wired_td = $(this).children('td.wired');
				var wireless_td = $(this).children('td.wireless');
				var mpos_td = $(this).children('td.mpos');
				
				//serial_no = serialno_td.children('input').val();
				
				stock_items = {
						'wired' : wired_td.children('input').val(),
						'wireless' : wireless_td.children('input').val(),
						'mpos' : mpos_td.children('input').val()
					};
				
			});
			
			//vendor_details['serial_no'] = serial_no;
			vendor_details['stock_items'] = stock_items;
			
			
			var mdr_facilities = {};
			$('table.mdr_facilities').children('tbody').children('tr').each(function(index, elmt){
				var facility_td = $(this).children('td.facility');
				var mid_td = $(this).children('td.mid_no');
				var mid_td2 = $(this).children('td.mid_no2');
				var type_td = $(this).children('td.type');
				var tid_td = $(this).children('td.tid_no');
				var item_td = $(this).children('td.tid_items');
				
				if(facility_td.children('input').val().length > 0){
					var facility_name = facility_td.children('input').val();
					var facility_type = type_td.children('input').val();
					
					if(mdr_facilities[facility_name] == null){
						mdr_facilities[facility_name] = {};
					}
					
					var mdr_facility_type = mdr_facilities[facility_name];
					
					mdr_facility_type[facility_type] = {
							'mid_no' : mid_td.children('input').val(),
							'mid_no2' : mid_td2.children('input').val(),
							'first_tid' : tid_td.children('input').val(),
							'tid_items' : item_td.children('input').val()
						};
					
					mdr_facilities[facility_name] = mdr_facility_type;
				}
			});
			
			vendor_details['mdr_facilities'] = mdr_facilities;
			
			
			var pos_ezypay_facilities = {};
			var pos_ezypay_arr = {};
			
			$('table.pos_ezypay').children('tbody').children('tr').each(function(index, elmt){
				var tid_td = $(this).children('td.tid_no');
				var type_td = $(this).children('td.type');
				var ezypay_plan = $(this).children('td.ezypay_plan');
				var mid_td = $(this).children('td.mid_no');
				var first_td = $(this).children('td.first_tid');
				
				var pos_ezypay_item = {
						'tid_no' : tid_td.children('input').val(),
						'type' : type_td.children('input').val(),
						'ezypay_plan' : ezypay_plan.children('input').val(),
						'mid_no' : mid_td.children('input').val(),
						'first_tid' : first_td.children('input').val()
					};
				
				if(pos_ezypay_facilities[tid_td.children('input').val()] != null) {
					pos_ezypay_arr = pos_ezypay_facilities[tid_td.children('input').val()];
				} else {
					pos_ezypay_arr = {};
				}
				
				pos_ezypay_arr['E' + ezypay_plan.children('input').val()] = pos_ezypay_item
				pos_ezypay_facilities[tid_td.children('input').val()] = pos_ezypay_arr;
			});
			
			vendor_details['pos_ezypay_facilities'] = pos_ezypay_facilities;
			
			
			
			var amex_ezypay_facilities = {};
			var amex_ezypay_arr = {};
			
			$('table.amex_ezypay').children('tbody').children('tr').each(function(index, elmt){
				var tid_td = $(this).children('td.tid_no');
				var type_td = $(this).children('td.type');
				var ezypay_plan = $(this).children('td.ezypay_plan');
				var mid_td = $(this).children('td.mid_no');
				var first_td = $(this).children('td.first_tid');
				var item_td = $(this).children('td.tid_items');
				
				var amex_ezypay_item = {
						'tid_no' : tid_td.children('input').val(),
						'type' : type_td.children('input').val(),
						'ezypay_plan' : ezypay_plan.children('input').val(),
						'mid_no' : mid_td.children('input').val(),
						'first_tid' : first_td.children('input').val()
					};
				
				
				if(amex_ezypay_facilities[tid_td.children('input').val()] != null) {
					amex_ezypay_arr = amex_ezypay_facilities[tid_td.children('input').val()];
				} else {
					amex_ezypay_arr = {};
				}
				
				amex_ezypay_arr['E' + ezypay_plan.children('input').val()] = amex_ezypay_item
				amex_ezypay_facilities[tid_td.children('input').val()] = amex_ezypay_arr;
			});
			
			vendor_details['amex_ezypay_facilities'] = amex_ezypay_facilities;
			
			
			var card_types = [];
			$('table.vendor_card_type').children('tbody').find('td').each(function(index, elmt){
				var checkbox = $(this).children('label').children('input[type=checkbox]');
				if(checkbox.is(':checked')){
					card_types.push(checkbox.val());
				}
			});
			
			vendor_details['card_types'] = card_types;
			
			
			elmt = document.form.diners_select;
			if($(elmt).is(':checked')){
				vendor_details['diners_select'] = $(elmt).val();
				
				elmt = document.form.diners_mid;
				vendor_details['diners_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['diners_select'] = '';
				vendor_details['diners_mid'] = '';
			}
			
			
			elmt = document.form.aeon_select;
			if($(elmt).is(':checked')){
				vendor_details['aeon_select'] = $(elmt).val();
				
				elmt = document.form.aeon_mid;
				vendor_details['aeon_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['aeon_select'] = '';
				vendor_details['aeon_mid'] = '';
			}
			
			
			elmt = document.form.genting_select;
			if($(elmt).is(':checked')){
				vendor_details['genting_select'] = $(elmt).val();
				
				elmt = document.form.genting_mid;
				vendor_details['genting_mid'] = $(elmt).val();
			} 
			else {
				vendor_details['genting_select'] = '';
				vendor_details['genting_mid'] = '';
			}
		}
		
		data['vendor_details'] = vendor_details;
		
		
		
		var edc_programme = [];
		$('table.edc_programme').children('tbody').find('td').each(function(index, elmt){
			var checkbox = $(this).children('label').children('input[type=checkbox]');
			if(checkbox.is(':checked')){
				edc_programme.push(checkbox.val());
			}
		});
		
		data['edc_programme'] = edc_programme;
		
		
		elmt = document.form.inst_remarks;
		data['inst_remarks'] = elmt.value;

		elmt = document.form.mbb_officer;
		data['mbb_officer'] = elmt.value;
		
		elmt = document.form.mbb_officer_handphone;
		data['mbb_officer_handphone'] = elmt.value;
		
		elmt = document.form.trm_rental_wired_amt;
		data['trm_rental_wired_amt'] = elmt.value;

		elmt = document.form.trm_rental_wireless_amt;
		data['trm_rental_wireless_amt'] = elmt.value;
		
		elmt = document.form.trm_deposit_amt;
		data['trm_deposit_amt'] = elmt.value;
		
		
		postdata += "&pos_form=" + encodeURIComponent(JSON.stringify(data));
		
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
            	if(typeof cb === 'function'){
            		cb();
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_notification',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},	
	delete_stock_vendor : function(case_id, merchant_id, outlet_id, vendor_name) {
		var postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += '&vendor_name=' + encodeURIComponent(vendor_name);
		
		if(confirm('Proceed to delete this vendor?')){
			var callback = function(json){
	            if(json.status == 'OK'){
	            	
	            	window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_pos&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id);
	            	
	            } else {
	            	mapUI.jq_message(json.message, 10);
	            }
	        };
			
	        var jq = {
	            'method' : 'POST',
	            'url' : jq_main_url + '/SubmitApp.do?dispatch=delete_pos_vendor',
	            'postdata' : postdata
	        };
	        
	        mapUI.jq_call(jq, callback);
		}
	},
	
	add_stock_vendor : function(merchant_id, case_id, app_no){
		elmt = document.form.stock_vendor;
		
		var vendor_name = elmt.value;
		if(vendor_name.length <= 0){
			mapUI.jq_message('Please select a vendor.', 10);
			return;
		}
		
		
		$('#stock_vendor_detail').children('div.detail').attr('data-name', vendor_name);
		$('table.generalinfo').children('tbody').children('tr.vendorname').children('td:eq(1)').children('input').val(vendor_name);
		
		$('table.stock_items').children('tbody').children('tr').each(function(index, elmt){
			var serialno_td = $(this).children('td.serialno');
			var wired_td = $(this).children('td.wired');
			var wireless_td = $(this).children('td.wireless');
			var mpos_td = $(this).children('td.mpos');
			
			serialno_td.children('input').val('');
			wired_td.children('input').val('');
			wireless_td.children('input').val('');
			mpos_td.children('input').val('');
		});
		
		
		$('table.mdr_facilities').children('tbody').empty();
		
		
		vendor._create_pos_form(merchant_id, case_id, function(){
			window.location.reload();
		});
	},
	
	generate_tid : function(merchant_id, case_id) {
		vendor._create_pos_form(merchant_id, case_id, function(){
			window.location.reload();
		});
	},
	
	create_pos_form : function(merchant_id, case_id) {
		vendor._create_pos_form(merchant_id, case_id, function(){
			mapUI.jq_message("POS Form has been saved successfully.", 10);
            	
        	var click_redirect = $('input#click_redirect').val();
        	if(click_redirect.length > 0) {
        		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
				var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
				
        		window.location.href = jq_main_url + click_redirect + sep + q;
        	}
        	else {
        		window.location.reload();
        	}
		});
	},
	create_notification : function(merchant_id, case_id){
		vendor._create_notification(merchant_id, case_id, function(){
			mapUI.jq_message("Notification has been saved successfully.", 10);
            	
        	var click_redirect = $('input#click_redirect').val();
        	if(click_redirect.length > 0) {
        		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
				var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
				
        		window.location.href = jq_main_url + click_redirect + sep + q;
        	}
        	else {
        		window.location.reload();
        	}
		});
		
      
	},
	create_esapl : function(case_id, outlet_id) {
		var elmt,postdata;
		var data = {};
		//visa & master
		elmt = document.getElementById('txt_visa_percent');
		data['vm_visap'] = elmt.value;
		
		elmt = document.getElementById('txt_vmc_on_us');
		data['vm_onusp'] = elmt.value;
		
		elmt = document.getElementById('txt_foreign_percent');
		data['vm_forp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_petrol');
		data['v_petrolp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_gov');
		data['v_govp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_charities');
		data['v_charp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_emarket');
		data['v_emarp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_insurance');
		data['v_insurp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_supermarket');
		data['v_supp'] = elmt.value;
		
		elmt = document.getElementById('txt_visa_utilities');
		data['v_utip'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_petrol');
		data['m_petrolp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_gov');
		data['m_govp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_charities');
		data['m_charp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_emarket');
		data['m_emarp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_insurance');
		data['m_insurp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_supermarket');
		data['m_supp'] = elmt.value;
		
		elmt = document.getElementById('txt_mc_utilities');
		data['m_utip'] = elmt.value;
		
		//amex
		elmt = document.getElementById('txt_amex_on_us');
		data['a_onusp'] = elmt.value;
		
		elmt = document.getElementById('txt_amex_playment_plan');
		data['a_plan'] = elmt.value;
		
		elmt = document.getElementById('txt_amex_interchange');
		data['a_intp'] = elmt.value;
		
		//interchange fee
		elmt = document.getElementById('txt_intfee_petrol');
		data['intf_petrol'] = elmt.value;
		
		elmt = document.getElementById('txt_intfee_ffood');
		data['intf_ffood'] = elmt.value;
		
		elmt = document.getElementById('txt_intfee_insurance');
		data['intf_insur'] = elmt.value;
		
		elmt = document.getElementById('txt_intfee_education');
		data['intf_edu'] = elmt.value;
		
		elmt = document.getElementById('txt_intfee_government');
		data['intf_gov'] = elmt.value;
		
		elmt = document.getElementById('txt_intfee_hypermarket');
		data['intf_hyp'] = elmt.value;
		
		//debit
		elmt = document.getElementById('txt_debit_mdr');
		data['d_mdr'] = elmt.value;
		
		elmt = document.getElementById('txt_debit_on_us_percent');
		data['d_onusp'] = elmt.value;
		
		//terminal
		elmt = document.getElementById('txt_terminal_rental_earning');
		data['ter_rental'] = elmt.value;
		
		elmt = document.getElementById('txt_overhead_maintenance_cost');
		data['lterm_cost'] = elmt.value;
		
		elmt = document.getElementById('txt_edc_terminal_cost');
		data['ledc_cost'] = elmt.value;

		elmt = document.getElementById('txt_annual_leaseline_cost');
		data['lsetup_leaseline'] = elmt.value;

		elmt = document.getElementById('txt_onetimesetup_cost');
		data['lots_cost'] = elmt.value;

		elmt = document.getElementById('txt_sim_cost1');
		data['lsim_cost1'] = elmt.value;

		elmt = document.getElementById('txt_tel_charges');
		data['ctel_charge'] = elmt.value;

		elmt = document.getElementById('txt_sponsorship_fee');
		data['lspon_fee'] = elmt.value;

		elmt = document.getElementById('txt_amex_tag_on');
		data['lamex_tgfee'] = elmt.value;

		elmt = document.getElementById('txt_amex_signing_fee');
		data['lsign_fee'] = elmt.value;

		elmt = document.getElementById('txt_setup_fee');
		data['lsetup_fee'] = elmt.value;

		elmt = document.getElementById('txt_sim_cost2');
		data['lsim_cost2'] = elmt.value;
		
		//edc cost
		elmt = document.getElementById('txt_wired_num');
		data['edc_wn'] = elmt.value;
		
		elmt = document.getElementById('txt_wired_cost');
		data['edc_wc'] = elmt.value;
		
		elmt = document.getElementById('txt_wireless_num');
		data['edc_wln'] = elmt.value;
		
		elmt = document.getElementById('txt_wireless_cost');
		data['edc_wlc'] = elmt.value;
		
		elmt = document.getElementById('txt_no_mbbedc_terminal');
		data['edc_nombb'] = elmt.value;
		
		elmt = document.getElementById('txt_terminal_cost_edc_permonth');
		data['edc_mcost'] = elmt.value;
		
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&esapl=" + encodeURIComponent(JSON.stringify(data));
		
		//System.out.println("@@@@@@");
		var callback = function(json){
            if(json.status == 'OK'){
            	//alert("ONE");
            	mapUI.jq_message("ESA PL has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	if(click_redirect.length > 0) {
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
    				var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
    				
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	//alert("TWO");
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_esapl',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	create_ezypay : function(case_id, outlet_id) {
		var elmt,postdata;
		var data = {};
		
		elmt = document.getElementById('txt_ezy6');
		data['ezycof6'] = elmt.value;
		
		elmt = document.getElementById('txt_ezy12');
		data['ezycof12'] = elmt.value;
		
		elmt = document.getElementById('txt_ezy18');
		data['ezycof18'] = elmt.value;
		
		elmt = document.getElementById('txt_ezy24');
		data['ezycof24'] = elmt.value;
		
		elmt = document.getElementById('txt_ezy30');
		data['ezycof30'] = elmt.value;
		
		elmt = document.getElementById('txt_ezy36');
		data['ezycof36'] = elmt.value;
		
		elmt = document.getElementById('txt_visa');
		data['visap'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales6');
		data['vmcs6'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales12');
		data['vmcs12'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales18');
		data['vmcs18'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales24');
		data['vmcs24'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales30');
		data['vmcs30'] = elmt.value;
		
		elmt = document.getElementById('txt_vmcsales36');
		data['vmcs36'] = elmt.value;
		
		elmt = document.getElementById('txt_asales6');
		data['asales6'] = elmt.value;
		
		elmt = document.getElementById('txt_asales12');
		data['asales12'] = elmt.value;
		
		elmt = document.getElementById('txt_asales18');
		data['asales18'] = elmt.value;
		
		elmt = document.getElementById('txt_asales24');
		data['asales24'] = elmt.value;
		
		elmt = document.getElementById('txt_asales30');
		data['asales30'] = elmt.value;
		
		elmt = document.getElementById('txt_asales36');
		data['asales36'] = elmt.value;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += "&ezypay=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	//alert("ONE");
            	mapUI.jq_message("EZY PAY has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	if(click_redirect.length > 0) {
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
    				var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
    				
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	//alert("TWO");
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_ezypay',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},

	vendor_inst_load : function(merchant_id, case_id) {		
		$(document.form.outlet_id).on('change', function() {
			var outlet_id = $(this).val();
			
			if(outlet_id.length > 0) {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_installation&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(case_id) + "&o_id=" + encodeURIComponent(outlet_id) + "#outlet_id";
			}
			else {
				window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_installation&m_id=" + encodeURIComponent(merchant_id) + "&c_id=" + encodeURIComponent(ase_id);
			}
		});
	},
	
	terminal_vendor_installation_search : function() {		
		var elmt, postdata;
		
		elmt = document.form.serial_no;
		if(elmt.value.length <= 0){
			mapUI.jq_message('Serial No. must not be blank.', 10);
			return;
		}
		
		postdata = 'serial_no=' + encodeURIComponent(elmt.value);
		
		window.location.href = jq_main_url + "/NewApp.do?dispatch=terminal_vendor_installation&" + postdata;
		
		
	},
	
	create_vendor_installation : function(merchant_id, case_id) {	
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&outlet_id=' + encodeURIComponent(elmt.value);
		
		
		var data = {};
		
		var vendor_name = $('div#vendor_install_detail').attr('data-name');
		if(vendor_name.length <= 0){
			mapUI.jq_message('Please select a vendor.', 10);
			return;
		}
		
		data['vendor_name'] = vendor_name;
		
		
		elmt = document.form.inst_status;
		if(elmt.value.length <= 0){
			mapUI.jq_message('Installation Status must not be blank.', 10);
			return;
		}
		
		data['inst_status'] = elmt.value;
		
		
		elmt = document.form.reschedule_date;
		if(data['inst_status'] == 'Reschedule'){
			if(elmt.value.length <= 0){
				mapUI.jq_message('Reschedule Date must not be blank.', 10);
				return;
			}
			
			if(elmt.value.is_date() == false){
				mapUI.jq_message('Invalid Reschedule Date format.', 10);
				return;
			}
		}
		
		data['reschedule_date'] = elmt.value;
		
		
		var terminal_detail = {};
		var last_install_date = '';
		var is_error = false;
		
		$('table.terminal_detail').children('tbody').children('tr').each(function(index, elmt){
			var mid_no = $(this).children('td.mid_no');
			var mid_no2 = $(this).children('td.mid_no2');
			var tid_no = $(this).children('td.tid_no');
			var tid_serial = $(this).children('td.tid_serial');
			var sim_serial = $(this).children('td.sim_serial');
			var sam_serial = $(this).children('td.sam_serial');
			var install_date = $(this).children('td.install_date');
			
			var item = {
					'mid_no' : mid_no.children('input').val(),
					'mid_no2' : mid_no2.children('input').val(),
					'tid_no' : tid_no.children('input').val(),
					'tid_serial' : tid_serial.children('input').val(),
					'sim_serial' : sim_serial.children('input').val(),
					'sam_serial' : sam_serial.children('input').val(),
					'install_date' : install_date.children('input').val()
				};
			
			
			if(data['inst_status'] == 'Successful'){
				if(item.install_date.length <= 0){
					mapUI.jq_message('Terminal Detail field must not be blank.', 10);
					is_error = true;
					return;
				}
			}
			
			if(item.install_date.length > 0) {
				if(item.install_date.is_date() == false){
					mapUI.jq_message('Invalid Install Date format.', 10);
					is_error = true;
					return;
				}
				
				last_install_date = item.install_date;
			}
			
			terminal_detail[tid_no.children('input').val()] = item;
		});
		
		
		if(is_error){
			return;
		}
		
		data['terminal_detail'] = terminal_detail;
		data['last_install_date'] = last_install_date;
		
		elmt = document.form.remark;
		if(data['inst_status'] == 'Cancel'){
			if(elmt.value.length <= 0){
				mapUI.jq_message('Remark must not be blank.', 10);
				return;
			}
		}
		
		data['remark'] = elmt.value;
		
		
		postdata += "&pos_install=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
        		mapUI.jq_message("Terminal-Vendor Installation Form has been saved successfully.", 10);
            	
            	var click_redirect = $('input#click_redirect').val();
            	if(click_redirect.length > 0) {
            		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
    				var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
    				
            		window.location.href = jq_main_url + click_redirect + sep + q;
            	}
            	else {
            		window.location.reload();
            	}
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_vendor_installation',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	
	close_appendix : function(event){
		$('div#appendix_frame').remove();
	},
	
	open_appendix_dcc : function(merchant_id, case_id){
		var elmt, postdata;
		
		postdata = 'c_id=' + encodeURIComponent(case_id);
		postdata += '&m_id=' + encodeURIComponent(merchant_id);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&o_id=' + encodeURIComponent(elmt.value);
		
		
		var html = '<div id="appendix_frame"><iframe frameborder="0" src="' + map_main_url  + '/NewApp.do?dispatch=appendix_dcc&' + postdata + '" style="width:100%; height:100%"></iframe></div>';
		
		$('body').append($(html));
		
		$('div#appendix_frame').on('click', function(event){
			event.stopPropagation();
		});
		
	},
	
	open_appendix_unionpay : function(merchant_id, case_id, vendor_name){
		var elmt, postdata;
		
		postdata = 'c_id=' + encodeURIComponent(case_id);
		postdata += '&m_id=' + encodeURIComponent(merchant_id);
		postdata += '&vendor_name=' + encodeURIComponent(vendor_name);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&o_id=' + encodeURIComponent(elmt.value);
		
		
		var html = '<div id="appendix_frame"><iframe frameborder="0" src="' + map_main_url  + '/NewApp.do?dispatch=appendix_unionpay&' + postdata + '" style="width:100%; height:100%"></iframe></div>';
		
		$('body').append($(html));
		
		$('div#appendix_frame').on('click', function(event){
			event.stopPropagation();
		});
		
	},
	
	open_appendix_partner : function(merchant_id, case_id, partner_name){
		var elmt, postdata;
		
		postdata = 'c_id=' + encodeURIComponent(case_id);
		postdata += '&m_id=' + encodeURIComponent(merchant_id);
		postdata += '&partner_name=' + encodeURIComponent(partner_name);
		
		elmt = document.form.outlet_id;
		if(elmt.value.length <= 0){
			mapUI.jq_message('For Outlet must not be blank.', 10);
			return;
		}
		
		postdata += '&o_id=' + encodeURIComponent(elmt.value);
		
		
		var html = '<div id="appendix_frame"><iframe frameborder="0" src="' + map_main_url  + '/NewApp.do?dispatch=appendix_partner&' + postdata + '" style="width:100%; height:100%"></iframe></div>';
		
		$('body').append($(html));
		
		$('div#appendix_frame').on('click', function(event){
			event.stopPropagation();
		});
		
	},
	
	create_appendix_dcc : function(merchant_id, case_id, outlet_id, notify_email){
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		
		if(notify_email == true){
			postdata += '&notify_email=Y';
		} else {
			postdata += '&notify_email=N';
		}
		
		elmt = document.form.email;
		if(notify_email == true && elmt.value.length <= 0){
			mapUI.jq_message('Email must not be blank.', 10);
			return;
		}
		
		postdata += '&email=' + encodeURIComponent(elmt.value);
		
		
		var data = {};
		
		elmt = document.form.start_date;
		data['start_date'] = elmt.value;
		
		elmt = document.form.contact_title;
		data['contact_title'] = elmt.value;
		
		elmt = document.form.contact_name;
		data['contact_name'] = elmt.value;
		
		elmt = document.form.contact_surname;
		data['contact_surname'] = elmt.value;
		
		elmt = document.form.contact_tel;
		data['contact_tel'] = elmt.value;
		
		elmt = document.form.contact_escalate_tel;
		data['contact_escalate_tel'] = elmt.value;
		
		elmt = document.form.contact_mobile;
		data['contact_mobile'] = elmt.value;
		
		elmt = document.form.contact_fax;
		data['contact_fax'] = elmt.value;
		
		elmt = document.form.contact_email;
		data['contact_email'] = elmt.value;
		
		elmt = document.form.contact_generic_email;
		data['contact_generic_email'] = elmt.value;
		
		postdata += "&appendix_data=" + encodeURIComponent(JSON.stringify(data));
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
        		mapUI.jq_message("DCC Order Form has been saved successfully.", 10);
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_appendix_dcc',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	create_appendix_unionpay : function(merchant_id, case_id, outlet_id, vendor_name, notify_email){
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += '&vendor_name=' + encodeURIComponent(vendor_name);
		
		if(notify_email == true){
			postdata += '&notify_email=Y';
		} else {
			postdata += '&notify_email=N';
		}
		
		
		elmt = document.form.email;
		if(notify_email == true && elmt.value.length <= 0){
			mapUI.jq_message('Email must not be blank.', 10);
			return;
		}
		
		postdata += '&email=' + encodeURIComponent(elmt.value);
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
        		mapUI.jq_message("UnionPay Submission has been sent.", 10);
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_appendix_unionpay',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	create_appendix_partner : function(merchant_id, case_id, outlet_id, partner_name){
		var elmt, postdata;
		
		postdata = 'case_id=' + encodeURIComponent(case_id);
		postdata += '&merchant_id=' + encodeURIComponent(merchant_id);
		postdata += '&outlet_id=' + encodeURIComponent(outlet_id);
		postdata += '&partner_name=' + encodeURIComponent(partner_name);
		
		elmt = document.form.email;
		if(elmt.value.length <= 0){
			mapUI.jq_message('Email must not be blank.', 10);
			return;
		}
		
		postdata += '&email=' + encodeURIComponent(elmt.value);
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
        		mapUI.jq_message("Vendor POS Form has been sent.", 10);
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=create_appendix_partner',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	get_email_address : function(){
		var elmt, postdata;
		
		$('table.generalinfo').children('tbody').children('tr.vendorname').each(function(index, elmt){
			var td = $(this).children('td:eq(1)');
			
			postdata = 'vendor=' + encodeURIComponent(td.children('select').val());
			
			if(td.children('select').val() == "OTHER"){
				$('#vendorname_other').prop('readonly', false);
			}else{
				$('#vendorname_other').prop('readonly', true);
			}
		});
		
		
		var callback = function(json){
            if(json.status == 'OK'){
            	
            	$('table.generalinfo').children('tbody').children('tr.vendoremail').children('td:eq(1)').children('input').val(json.email);
            	
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + '/SubmitApp.do?dispatch=get_email_address',
            'postdata' : postdata
        };
        
        mapUI.jq_call(jq, callback);
	},
	
	vendor_pos_search : function() {		
		var elmt, postdata;
		
		elmt = document.form.serial_no;
		if(elmt.value.length <= 0){
			mapUI.jq_message('Serial No. must not be blank.', 10);
			return;
		}
		
		postdata = 'serial_no=' + encodeURIComponent(elmt.value);
		
		//window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_pos_3&" + postdata;
		
		var callback = function(json){
            if(json.status == 'OK'){
            	window.location.href = jq_main_url + "/NewApp.do?dispatch=vendor_pos_3&serial_no=" +  json.serial_no;
            } else {
            	mapUI.jq_message(json.message, 10);
            }
        };
		
        var jq = {
            'method' : 'POST',
            'url' : jq_main_url + "/SubmitApp.do?dispatch=vendor_pos_3",
            'postdata' : postdata
        };
		
        mapUI.jq_call(jq, callback);
		
		
	},
	
	create_vendor_installation2 : function(merchant_id, case_id) {	
		var click_redirect = $('input#click_redirect').val();
    	if(click_redirect.length > 0) {
    		var sep = click_redirect.indexOf("?") >= 0 ? "&" : "?";
			var q = window.location.search.replace(/^\?dispatch=[\w]+&/, "");
			
    		window.location.href = jq_main_url + click_redirect + sep + q;
    	}
    	else {
    		window.location.reload();
    	}
	},
};